下载php56
http://cn2.php.net
解压:
tar -zxvf php-5.6.xx.tar.gz
进入php56目录,configure,
注意下自己安装目录
./configure --enable-fpm --with-fpm-user=www --with-fpm-group=www --prefix=/usr/local/php-56 --with-config-file-path=/etc/php/56 --sysconfdir=/etc/php/56 --with-config-file-scan-dir=/etc/php/56/conf.d --enable-mbstring --enable-pcntl --with-mysql=mysqlnd --with-zlib --with-png-dir --with-jpeg-dir --with-freetype-dir --with-gd --enable-gd-native-ttf --with-curl=shared --with-mysqli=mysqlnd --enable-soap=shared --enable-sockets=shared --enable-mysqlnd --with-pdo-mysql=mysqlnd --with-gettext=shared --with-mcrypt=shared --with-openssl=shared
将php56软链到/usr/sbin下
sudo ln -s /usr/local/php-56/bin/php php56
php扩展的目录,请看configure --prefix参数,如上配置
/usr/local/php-56/lib/php/extensions/,扩展的配置文件请看configure --with-config-file-path参数,如上
/etc/php/56,在/etc/php/56目录下建立conf.d目录,扩展配置的配置文件放到conf.d目录下,如mcrypt.so扩展配置文件mcrypt.ini
extension=mcrypt.so
添加php56-fpm service,在/etc/init.d目录下新建php56-fpm文件,文件内容
#! /bin/sh
### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts php-fpm
# Description: starts the PHP FastCGI Process Manager daemon
### END INIT INFO
prefix=/usr/local/php-56
exec_prefix=${prefix}
php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=/etc/php/56/php-fpm.conf
php_fpm_PID=${prefix}/var/run/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"
wait_for_pid () {
try=0
while test $try -lt 35 ; do
case "$1" in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;;
'removed')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac
echo -n .
try=`expr $try + 1`
sleep 1
done
}
case "$1" in
start)
echo -n "Starting php-fpm "
$php_fpm_BIN $php_opts
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
fi
wait_for_pid created $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
stop)
echo -n "Gracefully shutting down php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -QUIT `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed. Use force-quit"
exit 1
else
echo " done"
fi
;;
force-quit)
echo -n "Terminating php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -TERM `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reload service php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -USR2 `cat $php_fpm_PID`
echo " done"
;;
*)
echo "Usage: $0 {start|stop|force-quit|restart|reload}"
exit 1
;;
esac
修改下/etc/php/56/php.ini文件的扩展路径;