编译安装php5.4
目标:编译完成php5.4,并安装xcache。配合http2.4实现一个虚拟主机
操作系统CentOS6.6 x32_64
安装中使用的文件
/etc/sysconfig/network-scripts/ifcfg-eth0 配置
开始编译安装
安装完毕启动服务
按惯例上脚本php.sh
#!/bin/bash
php=php-5.4.31
xcache=xcache-3.1.0
# 本机IP
ip=172.16.32.231
# php安装路径
path=/usr/local/php5
# php页面文件的存放位置
webdire=/web
[ -d $webdire ] || mkdir -p $webdire
yum groupinstall -y "Development tools" "Server Platform Development"
yum install -y bzip2-devel libmcrypt-devel libxml2-devel
tar xf $php.tar.gz
tar xf $xcache.tar.bz2
[ -d /etc/php.d ] || mkdir -p /etc/php.d
cd $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-bz
make && make install
# 配置文件
cp php.ini-production /etc/php.ini
# 开机启动文件
cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
cp $path/etc/php-fpm.conf.default $path/etc/php-fpm.conf
sed -i "s/listen.*9000/listen = $ip:9000/" $path/etc/php-fpm.conf
# xcache install
cd $xcache
/usr/local/php5/bin/phpize
./configure --enable-xcache --with-php-config=$path/bin/php-config
make && make install > tmp.txt
xca=`grep -o '/.*$' tmp.txt`
sed -i "s@\(xcache.so\)@$xca/\1@" xcache.ini
cp xcache.ini /etc/php.d/
cd -
service php-fpm star
在/web目录下创建一个php文件 index.php
配置www1主机
web.sh
#!/bin/bash
# 开启ssl
rpm -ql mod_ssl &>>/dev/null || yum install -y mod_ssl
confile=/etc/httpd24/httpd.conf
[ -f $confile.bak ] && cp $confile.bak $confile
# 加载模块
sed -i 's@#*\(LoadModule ssl_module modules/mod_ssl.so\)@\1@' $confile
sed -i "s@#*ServerName www.example.com:80@ServerName `echo $HOSTNAME`@" $confile
# php
sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/' $confile
sed -i "s@#\(LoadModule proxy_module modules/mod_proxy.so\)@\1@" $confile
sed -i "s@#\(LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so\)@\1@" $confile
grep 'x-httpd-php' $confile || sed -i "s@\(AddType application/x-gzip .gz .tgz\)@\1\n AddType application/x-httpd-php .php\n AddType application/x-httpd-php-source .phps@" $confile
# 虚拟主机目录
docroot=/web/vhosts
# 日志目录
logpath=/var/log/httpd
# php服务器的ip地址
phpip=172.16.32.231
# 虚拟主机名
web1=vul.test.com
cat >> $confile <<EOF
<VirtualHost *:80>
DocumentRoot $docroot/www1
ServerName $web1
ErrorLog $logpath/www1.err
CustomLog $logpath/www1.access combined
<Directory $docroot/www1 >
Options None
Require ip 172.16
</Directory>
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://$phpip:9000/web/$1
</VirtualHost>
EOF
[ -d $docroot/www1 ] || mkdir -p $docroot/www1
[ -d $logpath ] || mkdir -p $logpath
cat > $docroot/www1/index.html <<EOF
this is $web1
EOF
# 如果开启selinux的话运行下面的语句
#chcon -R -u system_u -r object_r -t httpd_sts_content_t /web
service httpd24 restart
在DNSMaster添加vul=172.16.32.241 并将序列号+1
修改脚本dns.sh
/var/named/test.com.zone
ok,已正常工作。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。