lnmp 多版本php 同时运行
首先需要装好两个版本以上的PHP(例如:php5.6和php7两个版本)。这里假设你已安装完成。 1、配置并启动php默认版本: (设置 nginx 的 vhost 域名配置文件监听端口就好) 1).打开域名配置文件 # cd /usr/local/nginx/conf/vhost/ # vim yourdomain.com.conf 2.修改fastcgi_pass参数。 若希望该站点使用php5,则配置成: fastcgi_pass /tmp/php-cgi.sock; demo: location ~ \.php/?.*$ { root /home/wwwroot/tpshop; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; 若希望该站点使用php7,则配置成: fastcgi_pass php-cgi7.0.sock; demo: location ~ \.php/?.*$ { root /home/wwwroot/tpshop; fastcgi_pass unix:/tmp/php-cgi7.0.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; 最后刷新php-fpm 用 ps -ef | grep php-fpm 命令查fpm端口然后使用下面的命名就可以了。
zb@zb-computer:/usr/local/nginx/conf/vhost$ ps -ef | grep php-fpm
root 10205 2359 0 15:07 ? 00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
www 10206 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10207 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10208 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10209 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10210 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10211 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10212 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10213 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10214 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10215 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10216 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10217 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10218 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10219 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10220 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10221 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10223 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10224 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10226 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10227 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10228 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10229 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10230 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10231 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10232 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10233 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10234 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10235 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10236 10205 0 15:07 ? 00:00:00 php-fpm: pool www
www 10237 10205 0 15:07 ? 00:00:00 php-fpm: pool www
root 10238 2359 0 15:07 ? 00:00:00 php-fpm: master process (/usr/local/php7.2/etc/php-fpm.conf)
www 10239 10238 0 15:07 ? 00:00:00 php-fpm: pool www
www 10240 10238 0 15:07 ? 00:00:00 php-fpm: pool www
zb 12444 6564 0 15:14 pts/19 00:00:00 grep --color=auto php-fpm
现在有了2个master 进程
kill -USR2 10238 至此,配置启动多版本php完成。