Centos6.7 编译安装 Apache PHP

##### Apache 编译安装 ####

[root@localhost~]#yuminstallgccgcc-c++makewget[root@localhost~]#yuminstallzlib-developenssl-devel[root@localhost~]#yuminstall-yperlperl-devel1)apr[root@localhostsrc]#wgethttp://mirror.bit.edu.cn/apache//apr/apr-1.5.2.tar.gz[root@localhostsrc]#tarzxvfapr-1.5.2.tar.gz[root@localhostsrc]#cdapr-1.5.2[root@localhostapr-1.5.2]#./configure--prefix=/usr/local/apache/apr[root@localhostapr-1.5.2]#make&&makeinstall2)apr-util

[root@localhostsrc]#wgethttp://mirror.bit.edu.cn/apache//apr/apr-util-1.5.4.tar.gz[root@localhostsrc]#tarzxvfapr-util-1.5.4.tar.gz[root@localhostsrc]#cdapr-util-1.5.4[root@localhostapr-util-1.5.4]#./configure--prefix=/usr/local/apache/apr-util--with-apr=/usr/local/apache/apr[root@localhostapr-util-1.5.4]#make&&makeinstall3)pcre[root@localhostsrc]#wgetftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz[root@localhostsrc]#tarzxvfpcre-8.37.tar.gz[root@localhostsrc]#cdpcre-8.37[root@localhostpcre-8.37]#./configure[root@localhostpcre-8.37]#make&&makeinstall4)apache[root@localhost~]#cd/usr/local/src/[root@localhost~]#wgethttp://mirrors.cnnic.cn/apache//httpd/httpd-2.4.17.tar.gz[root@localhostsrc]#tarzxvfhttpd-2.4.17.tar.gz[root@localhostsrc]#cdhttpd-2.4.17[root@localhosthttpd-2.4.17]#./configure--prefix=/usr/local/apache\--with-apr=/usr/local/apache/apr/bin/apr-1-config\--with-apr-util=/usr/local/apache/apr-util/bin/apu-1-config\--enable-module=so\--enable-mods-shared=all\--enable-deflate\--enable-expires\--enable-headers\--enable-cache\--enable-file-cache\--enable-mem-cache\--enable-disk-cache\--enable-mime-magic\--enable-authn-dbm\--enable-vhost-alias\--enable-so\--enable-rewrite\--enable-ssl\--with-mpm=prefork[root@localhosthttpd-2.4.17]#make&&makeinstall#index.php#AddHandlerphp5-script.php#AddTypetext/html.php######httpdend###########[root@localhost~]#ln-s/usr/local/apache/conf/etc/httpd[root@localhost~]#ln-s/usr/local/apache/bin/*/usr/sbin/[root@localhost~]#touch/etc/init.d/httpd[root@localhost~]#chmod755/etc/init.d/httpd[root@localhost~]#vi/etc/init.d/httpd#!/bin/bash##httpdStartupscriptfortheApacheHTTPServer##chkconfig:-8515#description:TheApacheHTTPServerisanefficientandextensible\#serverimplementingthecurrentHTTPstandards.#processname:httpd#config:/etc/httpd/conf/httpd.conf#config:/etc/sysconfig/httpd#pidfile:/var/run/httpd/httpd.pid####BEGININITINFO#Provides:httpd#Required-Start:$local_fs$remote_fs$network$named#Required-Stop:$local_fs$remote_fs$network#Should-Start:distcache#Short-Description:startandstopApacheHTTPServer#Description:TheApacheHTTPServerisanextensibleserver#implementingthecurrentHTTPstandards.###ENDINITINFO#Sourcefunctionlibrary../etc/rc.d/init.d/functionsif[-f/etc/sysconfig/httpd];then./etc/sysconfig/httpdfiHTTPD_LANG=${HTTPD_LANG-"C"}INITLOG_ARGS=""apachectl=/usr/sbin/apachectlhttpd=${HTTPD-/usr/sbin/httpd}prog=httpdpidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd}RETVAL=0STOP_TIMEOUT=${STOP_TIMEOUT-10}start(){echo-n$"Starting$prog:"LANG=$HTTPD_LANGdaemon--pidfile=${pidfile}$httpd$OPTIONSRETVAL=$?echo[$RETVAL=0]&&touch${lockfile}return$RETVAL}stop(){echo-n$"Stopping$prog:"killproc-p${pidfile}-d${STOP_TIMEOUT}$httpdRETVAL=$?echo[$RETVAL=0]&&rm-f${lockfile}${pidfile}}reload(){echo-n$"Reloading$prog:"if!LANG=$HTTPD_LANG$httpd$OPTIONS-t>&/dev/null;thenRETVAL=6echo$"notreloadingduetoconfigurationsyntaxerror"failure$"notreloading$httpdduetoconfigurationsyntaxerror"else#ForceLSBbehaviourfromkillprocLSB=1killproc-p${pidfile}$httpd-HUPRETVAL=$?if[$RETVAL-eq7];thenfailure$"httpdshutdown"fifiecho}case"$1"instart)start;;stop)stop;;status)status-p${pidfile}$httpdRETVAL=$?;;restart)stopstart;;condrestart|try-restart)ifstatus-p${pidfile}$httpd>&/dev/null;thenstopstartfi;;force-reload|reload)reload;;graceful|help|configtest|fullstatus)$apachectl$@RETVAL=$?;;*)echo$"Usage:$prog{start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"RETVAL=2esacexit$RETVAL[root@localhost~]#chkconfig--addhttpd[root@localhost~]#chkconfighttpdon

##### PHP 编译安装 ####

[root@localhost~]#yuminstalllibxml2-develcurl-devellibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-develnet-snmpnet-snmp-devel[root@localhostsrc]#wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz[root@localhostsrc]#tarzxvflibiconv-1.14.tar.gz[root@localhostsrc]#cdlibiconv-1.14[root@localhostlibiconv-1.14]#./configure--prefix=/usr/local/php/libiconv[root@localhostlibiconv-1.14]#make&&makeinstall[root@localhostsrc]#wgethttp://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz[root@localhostsrc]#tarzxvflibmcrypt-2.5.8.tar.gz[root@localhostsrc]#cdlibmcrypt-2.5.8[root@localhostlibmcrypt-2.5.8]#./configure[root@localhostlibmcrypt-2.5.8]#make&&makeinstall[root@localhostlibltdl]#/sbin/ldconfig&&cdlibltdl/[root@localhostlibltdl]#./configure--enable-ltdl-install[root@localhostlibltdl]#make&&makeinstall[root@localhostsrc]#wgethttp://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz[root@localhostsrc]#tarzxvfmhash-0.9.9.9.tar.gz[root@localhostsrc]#cdmhash-0.9.9.9[root@localhostmhash-0.9.9.9]#./configure[root@localhostmhash-0.9.9.9]#make&&makeinstall[root@localhostsrc]#wgethttp://nchc.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz[root@localhostsrc]#tarzxvfmcrypt-2.6.8.tar.gz[root@localhostsrc]#cdmcrypt-2.6.8[root@localhostmcrypt-2.6.8]#/sbin/ldconfig&&exportLD_LIBRARY_PATH=/usr/local/lib:LD_LIBRARY_PATH[root@localhostmcrypt-2.6.8]#./configure[root@localhostmcrypt-2.6.8]#make&&makeinstall[root@localhostsrc]#wgethttp://cn2.php.net/distributions/php-5.6.15.tar.gz[root@localhostsrc]#tarzxvfphp-5.6.15.tar.gz[root@localhostsrc]#cdphp-5.6.15[root@localhostphp-5.6.15]#./configure--prefix=/usr/local/php\--with-config-file-path=/usr/local/php/etc\--with-iconv=/usr/local/php/libiconv\--with-apxs2=/usr/local/apache/bin/apxs\--with-mysql=mysqlnd\--with-mysqli=mysqlnd\--with-pdo-mysql=mysqlnd\--with-gd\--with-jpeg-dir\--with-png-dir\--with-pear\--with-freetype-dir\--with-zlib\--with-libxml-dir\--with-iconv-dir\--with-xmlrpc\--with-mhash\--with-mcrypt\--with-curl\--with-openssl\--with-snmp\--with-gettext\--enable-pdo\--enable-mbstring\--enable-ctype\--enable-simplexml\--enable-ftp\--enable-sockets\--enable-gd-native-ttf\--enable-sysvsem\--enable-exif\--enable-sysvshm\--enable-xml\--enable-dom\--enable-simplexml\--enable-shmop\--enable-zip\--enable-mbregex\--enable-bcmath\--enable-inline-optimization\--enable-soap[root@localhostphp-5.6.15]#make&&makeinstall[root@localhostphp-5.6.15]#cpphp.ini-production/usr/local/php/etc/php.ini[root@localhost~]#ln-s/usr/local/php/bin/*/usr/sbin/