应一个兄弟帮忙的需求操作这个,兄弟的服务器,一个需要zend+php 5.4 ,一个网站需要 5.3,
之前兄弟直接买了2个服务器,感觉太浪费钱了,于是给他搭建了下,有了以下搭建笔记:
基本上是shell,各位自己试试,深夜了,写的有点乱,有问题留言,
php5.3 我就不管了,网上一堆教程,或者使用lnmp一键安装包各种爽歪歪,
主要说下php5.3和php5.4共存的搭建笔记,源码是 军哥的网站盗的,哈哈
#!/bin/bash
echo "[+] Installing Php 5.4..."
wget http://soft.vpser.net/web/php/php-5.4.41.tar.gz
tar zxvf php-5.4.41.tar.gz php-5.4.41
cd php-5.4.41
./configure --prefix=/usr/local/php54 --with-config-file-path=/usr/local/php54/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo
make ZEND_EXTRA_LIBS='-liconv'
make install
#ln -sf /usr/local/php54/bin/php /usr/bin/php54
#ln -sf /usr/local/php54/bin/phpize /usr/bin/phpize54
#ln -sf /usr/local/php54/bin/pear /usr/bin/pear54
#ln -sf /usr/local/php54/bin/pecl /usr/bin/pecl54
#if [ "${Stack}" = "lnmp" ]; then
# ln -sf /usr/local/php54/sbin/php-fpm /usr/bin/php-fpm54
#fi
echo "Copy new php configure file..."
mkdir -p /usr/local/php54/etc
cp php.ini-production /usr/local/php54/etc/php.ini
# php extensions
echo "Modify php.ini......"
sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /usr/local/php54/etc/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /usr/local/php54/etc/php.ini
sed -i 's/;date.timezone =/date.timezone = PRC/g' /usr/local/php54/etc/php.ini
sed -i 's/short_open_tag = Off/short_open_tag = On/g' /usr/local/php54/etc/php.ini
sed -i 's/; cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /usr/local/php54/etc/php.ini
sed -i 's/; cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/g' /usr/local/php54/etc/php.ini
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /usr/local/php54/etc/php.ini
sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /usr/local/php54/etc/php.ini
sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /usr/local/php54/etc/php.ini
#Pear_Pecl_Set ??
#
cd ../
echo "Install ZendGuardLoader for PHP 5.4..."
wget http://soft.vpser.net/web/zend/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
tar zxf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
mkdir -p /usr/local/zend54/
cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so /usr/local/zend54/
echo "Write ZendGuardLoader to php.ini..."
cat >>/usr/local/php54/etc/php.ini<<EOF
;eaccelerator
;ionCube
[Zend ZendGuard Loader]
zend_extension=/usr/local/zend54/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
;xcache
;xcache end
EOF
echo "Creating new php-fpm configure file..."
cat >/usr/local/php54/etc/php-fpm.conf<<EOF
[global]
pid = /usr/local/php54/var/run/php-fpm.pid
error_log = /usr/local/php54/var/log/php-fpm.log
log_level = notice
[www]
listen = 127.0.0.1:9009
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow54.log
EOF
echo "Copy php-fpm init.d file..."
cd php-5.4.41
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm54
chmod +x /etc/init.d/php-fpm54
# 注意:/etc/init.d/php-fpm54 的 这个要改下:prefix=/usr/local/php 改为:prefix=/usr/local/php54
#重启下php-fpm
#顺便原来的php-fpm 5.3 的端口 改为 listen = 127.0.0.1:9000
#nginx使用的时候,使用对应的端口即可 :
# #fastcgi_pass unix:/tmp/php-cgi.sock;
# fastcgi_pass 127.0.0.1:9000; //5.3
# fastcgi_pass 127.0.0.1:9009; //5.4
#
# 重启:5.3 就 /etc/init.d/php-fpm start
# 重启:5.4 就 /etc/init.d/php-fpm54 start
## 最后给他设置下自启动吧。update-rc.d -f php-fpm54 defaults
#我这个是 Ubuntu哈。。。。
#