前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >nginx配合两个或多个PHP版本。php5.6与php7

nginx配合两个或多个PHP版本。php5.6与php7

原创
作者头像
conanma
发布2021-12-02 15:43:27
1.7K0
发布2021-12-02 15:43:27
举报
文章被收录于专栏:正则正则

由于我的PHP7是通过brew安装的。

brew安装的东西都在目录/usr/local/opt/ 下了。这是我知识的盲点。所以找了很久没找到。

看到这篇文章后,到了/usr/local/opt/php71/sbin/ 目录下果然看到了php-fpm

接下来的事情很容易了

sudo ln -s /usr/local/opt/php71/sbin/php-fpm /usr/sbin/php-fpm 将它软连接过去,

没有使用cp ,因为/usr/sbin/已经有个5.6了,我想以后可以做切换使用。

有人说mac不支持 多个PHP版本切换,我证明了,是可以的。

实现配置2个版本PHP,

修改php7的php-fmp服务端口号

进入到目录:/usr/local/etc/php/php7.1/php-fpm.d/www.conf

修改 www.conf这个文件的监听端口listen = 127.0.0.1:9009

可以了。

现在的情况是:

PHP5.6的php-fpm监听的是 127.0.0.1:9000

PHP7.1的php-fpm监听的是 127.0.0.1:9009

有了这两个那就可以在nginx上干活了

进入nginx配置目录

/usr/local/etc/nginx/nginx.conf

一下是nginx配置:(注意看两个server 的 fastcgi_pass:后面监听的端口)

9987-> 127.0.0.1:9000 ->PHP5.6

9988-> 127.0.0.1:9009 ->PHP7.1

server {

listen 9987;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

root /Volumes/data/DockerTools/code/advanced_dev/frontend/web;

index index.php,index.html index.htm;

try_files $uri $uri/ /index.php?$args;

}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html

#

error_page 500 502 503 504 /50x.html;

#location = /50x.html {

# root html;

#}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ \.php$ {

# proxy_pass http://127.0.0.1;

#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

root /Volumes/data/DockerTools/code/advanced_dev/frontend/web;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

#location ~ /\.ht {

# deny all;

#}

}

server {

listen 9988;

server_name boo.local.anlewo.com;

#access_log /log/frontend.local.anlewo.access.log main;

location / {

root /Volumes/data/DockerTools/code/advanced_dev/frontend/web;

index index.php index.html index.htm;

try_files $uri $uri/ /index.php?$args;

}

location ~ \.php$ {

root /Volumes/data/DockerTools/code/advanced_dev/frontend/web;

fastcgi_pass 127.0.0.1:9009;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档