
正文
centos6.5 安装php-5.6.31
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
1 从PHP官网下载所需要的PHP版本
下载地址: http://php.net/get/php-5.6.31.tar.gz/from/a/mirror 把下载好的文件上传到服务器
2 安装PHP所需要的扩展
yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel
gd gd-devel
3 安装PHP
tar -zxvf php-5.6.31.tar.gz
cd php-5.6.31
./configure --prefix=/usr/local/php5.6 --disable-debug --enable-shared --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-libxml-dir --with-openssl --with-bz2 --with-mcrypt --enable-gd-native-ttf --with-curl --with-zlib-dir -with-gettext --with-jpeg-dir --with-png-dir --with-bz2 --with-freetype-dir --with-iconv --with-config-file-path=/usr/local/php5.6/etc --enable-mbstring --with-gd --disable-debug --enable-short-tags --disable-posix --enable-exif --enable-ftp --enable-sockets --with-mhash --enable-zip
make
make install
cp php.ini-production /usr/local/php5.6/etc/php.ini
4 配置PHP
编辑php.in文件 修改内容如下
short_open_tag = Ondisable_functions = "dl,exec,passthru,pcntl_exec,popen,posix_kill,posix_mkfifo,posix_setuid,proc_close,proc_open,
proc_terminate,shell_exec,system,leak,posix_setpgid,posix_setsid,proc_get_status,proc_nice,show_source"expose_php = Offcgi.fix_pathinfo=date.timezone = Asia/Shanghai
编辑php-fpm.conf
cp php-fpm.conf.default php-fpm.conf
编辑 php-fpm.conf 设置如下
pid = /usr/local/php5.6/var/run/php-fpm.piderror_log = log/php-fpm.loglog_level = noticeprocess_control_timeout = 30events.mechanism = epolllisten = 127.0.0.1:9056listen.backlog = -1pm.max_children = 1024pm.start_servers = 80pm.min_spare_servers = 20pm.max_spare_servers = 80pm.max_requests = 2000pm.status_path = /statusping.path = /pingping.response = pongslowlog = var/log/phpslow_$pool.logrequest_slowlog_timeout = 5srequest_terminate_timeout = 60srlimit_files = 65534php_admin_value[open_basedir] = "/tmp/"
php_admin_value[disable_functions] = dl,exec,leak,passthru,pcntl_exec,popen,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,system
5 启动测试PHP
#测试php-fpm配置
/usr/local/php5.6/sbin/php-fpm -t
/usr/local/php5.6/sbin/php-fpm -c /usr/local/php5.6/etc/php.ini -y /usr/local/php5.6/etc/php-fpm.conf -t
#启动php-fpm
/usr/local/php5.6/sbin/php-fpm
/usr/local/php5.6/sbin/php-fpm -c /usr/local/php7/etc/php.ini -y /usr/local/php5.6/etc/php-fpm.conf
#关闭php-fpm
kill -INT `cat /usr/local/php5.6/var/run/php-fpm.pid`
#重启php-fpm
kill -USR2 `cat /usr/local/php5.6/var/run/php-fpm.pid`







