linux中同一伺服器php2個版本php5.3和php5.4共存的搭建筆記

來源:互聯網
上載者:User

應一個兄弟幫忙的需求操作這個,兄弟的伺服器,一個需要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哈。。。。
#

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.