系统有个php5.5.14 现在需要再安装个php5.6.31

1.php.net 下载php5.6.31并安装

tar zxvf php-5.6.31.tar.gz

cd php-5.6.31

./configure –prefix=/usr/local/php56 –with-config-file-path=/usr/local/php56/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 –enable-opcache –enable-intl –with-xsl

遇到一些错误 参考http://www.bkjia.com/PHPjc/1008013.html

configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.

安装 libicu-devel

yum -y install libicu-devel

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

安装 libxslt-devel
yum -y install libxslt-devel

注意一下make
make ZEND_EXTRA_LIBS=’-liconv’

make install

2
拷贝配置文件
cp -R ./sapi/fpm/php-fpm.conf /usr/local/php56/etc/php-fpm.conf
cp php.ini-development /usr/local/php56/etc/php.ini
cp /etc/init.d/php-fpm /etc/init.d/php-fpm56
php-fpm56修改一下PHP的目录就可以了

4.配置php-fpm 修改php-fpm.conf的侦听端口为9001,因为主版本5.5.14是侦听9000。 killall php-fpm56

/usr/local/php56/etc/php-fpm.conf

listen = 127.0.0.1:9001

配置PHP.ini

# php extensions
echo “Modify php.ini……”
sed -i ‘s/post_max_size =.*/post_max_size = 50M/g’ /usr/local/php56/etc/php.ini
sed -i ‘s/upload_max_filesize =.*/upload_max_filesize = 50M/g’ /usr/local/php56/etc/php.ini
sed -i ‘s/;date.timezone =.*/date.timezone = PRC/g’ /usr/local/php56/etc/php.ini
sed -i ‘s/short_open_tag =.*/short_open_tag = On/g’ /usr/local/php56/etc/php.ini
sed -i ‘s/;cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/g’ /usr/local/php56/etc/php.ini
sed -i ‘s/max_execution_time =.*/max_execution_time = 300/g’ /usr/local/php56/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/php56/etc/php.ini

echo “Creating new php-fpm configure file…”
cat >/usr/local/php56/etc/php-fpm.conf<<EOF
[global]
pid = /usr/local/php56/var/run/php-fpm.pid
error_log = /usr/local/php56/var/log/php-fpm.log
log_level = notice

[www]
listen = /tmp/php56-cgi.sock
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/php56slow.log
EOF

fastcgi_pass 127.0.0.1:9001;
下面备注一下需要装一些库

extension=yaf.so
extension=memcache.so
extension=memcached.so
extension=redis.so
extension=bz2.so

下面是个文件,请下载查看

安装多版本php

Comments are closed.

Post Navigation