编译安装php5.4

目标:编译完成php5.4,并安装xcache。配合http2.4实现一个虚拟主机

操作系统CentOS6.6x32_64

安装中使用的文件

/etc/sysconfig/network-scripts/ifcfg-eth0配置


开始编译安装

安装完毕启动服务

按惯例上脚本php.sh

#!/bin/bashphp=php-5.4.31xcache=xcache-3.1.0#本机IPip=172.16.32.231#php安装路径path=/usr/local/php5#php页面文件的存放位置webdire=/web[-d$webdire]||mkdir-p$webdireyumgroupinstall-y"Developmenttools""ServerPlatformDevelopment"yuminstall-ybzip2-devellibmcrypt-devellibxml2-develtarxf$php.tar.gztarxf$xcache.tar.bz2[-d/etc/php.d]||mkdir-p/etc/php.dcd$php./configure--prefix=$path--with-mysql=mysqlnd--with-pdo-mysql=mysqlnd--with-mysqli=mysqlnd--with-openssl--enable-mbstring--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir=/usr--enable-xml--enable-sockets--enable-fpm--with-mcrypt--with-config-file-path=/etc/php--with-config-file-scan-dir=/etc/php/php.d--with-bzmake&&makeinstall#配置文件cpphp.ini-production/etc/php.ini#开机启动文件cpsapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-fpmchmod+x/etc/rc.d/init.d/php-fpmchkconfig--addphp-fpmchkconfigphp-fpmoncp$path/etc/php-fpm.conf.default$path/etc/php-fpm.confsed-i"s/listen.*9000/listen=$ip:9000/"$path/etc/php-fpm.conf#xcacheinstallcd$xcache/usr/local/php5/bin/phpize./configure--enable-xcache--with-php-config=$path/bin/php-configmake&&makeinstall>tmp.txtxca=`grep-o'/.*$'tmp.txt`sed-i"s@\(xcache.so\)@$xca/\1@"xcache.inicpxcache.ini/etc/php.d/cd-servicephp-fpmstar

在/web目录下创建一个php文件 index.php


配置www1主机

web.sh

#!/bin/bash#开启sslrpm-qlmod_ssl&>>/dev/null||yuminstall-ymod_sslconfile=/etc/httpd24/httpd.conf[-f$confile.bak]&&cp$confile.bak$confile#加载模块sed-i's@#*\(LoadModulessl_modulemodules/mod_ssl.so\)@\1@'$confilesed-i"s@#*ServerNamewww.example.com:80@ServerName`echo$HOSTNAME`@"$confile#phpsed-i's/DirectoryIndexindex.html/DirectoryIndexindex.phpindex.html/'$confilesed-i"s@#\(LoadModuleproxy_modulemodules/mod_proxy.so\)@\1@"$confilesed-i"s@#\(LoadModuleproxy_fcgi_modulemodules/mod_proxy_fcgi.so\)@\1@"$confilegrep'x-httpd-php'$confile||sed-i"s@\(AddTypeapplication/x-gzip.gz.tgz\)@\1\nAddTypeapplication/x-httpd-php.php\nAddTypeapplication/x-httpd-php-source.phps@"$confile#虚拟主机目录docroot=/web/vhosts#日志目录logpath=/var/log/httpd#php服务器的ip地址phpip=172.16.32.231#虚拟主机名web1=vul.test.comcat>>$confile<<EOF<VirtualHost*:80>DocumentRoot$docroot/www1ServerName$web1ErrorLog$logpath/www1.errCustomLog$logpath/www1.accesscombined<Directory$docroot/www1>OptionsNoneRequireip172.16</Directory>ProxyRequestsOffProxyPassMatch^/(.*\.php)$fcgi://$phpip:9000/web/$1</VirtualHost>EOF[-d$docroot/www1]||mkdir-p$docroot/www1[-d$logpath]||mkdir-p$logpathcat>$docroot/www1/index.html<<EOFthisis$web1EOF#如果开启selinux的话运行下面的语句#chcon-R-usystem_u-robject_r-thttpd_sts_content_t/webservicehttpd24restart

在DNSMaster添加vul=172.16.32.241 并将序列号+1

修改脚本dns.sh

/var/named/test.com.zone


ok,已正常工作。