如何让 Nginx 使用替代的 PHP 版本? [英] How to get Nginx to use alternative PHP version?
问题描述
我有一个运行 Nginx 的 Ubuntu 网络服务器.我运行的是 PHP 5.5.30,我使用以下命令安装了 PHP 5.6.23:
I have an Ubuntu web server running Nginx. I was runngin PHP 5.5.30 and I installed PHP 5.6.23 using the following commands:
1) sudo apt-add-repository ppa:ondrej/php
2) sudo apt-get update
3) sudo apt-get install php5.6
安装在以前版本的 PHP (/etc/php/5.6/) 的新路径下.当我从网页运行 phpinfo() 命令时,我仍然让它在旧版本的 PHP (5.5.30) 下运行 - 如何让 Nginx 查看新安装?
The installation is under a new path from the previous verison of PHP (/etc/php/5.6/). When I run a phpinfo() command from a web page I still get it running under the old version of PHP (5.5.30) - how do I get Nginx looking at the new installation?
附言当我从命令行运行 php --version 时,它显示 PHP 5.6.23 !p.p.s 我的 nginx.conf 文件包含 fastcgi_pass unix:/run/php/php5.6-fpm.sock;
p.s. When I run php --version from the command line it show PHP 5.6.23 !
p.p.s My nginx.conf file contains fastcgi_pass unix:/run/php/php5.6-fpm.sock;
推荐答案
我有同样的问题.您忘记将默认套接字从 fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
更改为 fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
- 你可以在 /etc/nginx/sites-available/default
找到配置文件.
I have the same problem. You forgot to change the default sockets from fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
to fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
- you can find the configuration file at /etc/nginx/sites-available/default
.
之前:
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
之后:
fastcgi_pass unix:/run/php/php5.6-fpm.sock;
这篇关于如何让 Nginx 使用替代的 PHP 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!