PHP 5.2.6 安装及fpm补丁,实现php多版本共存

WBOY
Release: 2016-06-23 13:11:31
Original
1226 people have browsed it

  公司最近把一个项目交给外包做了,那叫一个坑啊!简直气得我吐血,文档里面只提到用php5,我就装了php5.6。什么都搞好之后告诉我说php版本要5.2.6。我只能呵呵了···5.2.6默认不支持php-fpm。所以还要打补丁各种问题,下面是安装记录,免得下次再重蹈覆辙···

依赖安装

 yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel mysql mysql-devel -y
Copy after login

下载安装包

cd /opt/wget http://php-fpm.org/downloads/php-5.2.6-fpm-0.5.9.diff.gzwget http://museum.php.net/php5/php-5.2.6.tar.gz
Copy after login

解压和打补丁

tar zxvf php-5.2.6.tar.gzgzip -cd php-5.2.6-fpm-0.5.9.diff.gz | patch -d php-5.2.6 -p1
Copy after login

打完补丁后编译参数就支持

注:--enable-fastcgi \ 需要在--enable-fpm \的前面,否则,fpm不能编译上。

--enable-fpm
Copy after login

编译及安装

cd php-5.2.6./configure \--prefix=/data/php-5.2.6 \--with-config-file-path=/data/php-5.2.6/etc \--enable-inline-optimization \--disable-debug \--disable-rpath \--enable-shared \--enable-fastcgi \--enable-fpm \--with-mysql=/usr/bin/mysql \--with-mysqli=/usr/bin/mysql_config \--with-pdo-mysql=/usr/bin/mysql \--with-gettext \--enable-mbstring \--with-iconv \--with-mcrypt \--with-mhash \--enable-bcmath \--enable-soap \--with-libxml-dir \--enable-pcntl \--enable-shmop \--enable-sysvmsg \--enable-sysvsem \--enable-sysvshm \--enable-sockets \--with-curl \--with-zlib \--enable-zip \--with-bz2 \--with-readlinemake -j4 && make install
Copy after login

配置

cp php.ini-dist  /data/php-5.2.6/etc/php.inicd /data/php-5.2.6/vim etc/php-fpm.conf
Copy after login
需要注意下面几处配置<value name="listen_address">127.0.0.1:9100</value>这个表示php的fastcgi进程监听的ip地址以及端口。因为本地已经有一个5.6版本了所以这里改成9100<value name="user">nobody</value><value name="group">nobody</value>表示php的fastcgi进程以什么用户以及用户组来运行,默认该行是注释掉的,需要打开<value name="display_errors">0</value>是否显示php错误信息<value name="max_children">5</value>最大的子进程数目运行php-fpm:php-fpm用一个程序来控制fastcgi进程,这个文件在$PREFIX/sbin/php-fpm
Copy after login

nginx 配置

location ~ \.php$ {            root           /data/www/yydb;            fastcgi_pass   127.0.0.1:9100;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name;            include        fastcgi_params;        }
Copy after login

这里把fastcgi_pass 改到本地的9100端口

启动

/data/php-5.2.6/sbin/php-fpm startecho "/data/php-5.2.6/sbin/php-fpm start" >> /etc/rc.local
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!