5

多nginx单php-fpm的配置方法

 3 years ago
source link: https://blogread.cn/it/article/598?f=hot1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

多nginx单php-fpm的配置方法

浏览:3034次  出处信息

    用php fastcgi和nginx搭配的形式是很常见的,在很BT的需求下,可能会需要多个nginx走不同的端口,而进程只用一个php-fpm。

    本文所讲的环境比上述一句话还要BT,存在一个php-fpm,而且每个nginx都以一个非超级用户所有来进行运行。

    这样就存在了一个BT的情况,php-fpm默认不能以root权限运行,而普通用户来运行的话,对其他用户的目录,php-fpm将没有权限,页面在运行php的时候,会提示404。

    于是有以下的解决方案:

    找到php的源代码 $src_path/sapi/cgi/fpm/fpm_unix.c

    在文件顶部增加一个宏定义:#define I_REALLY_WANT_ROOT_PHP

    重新 configure make make install

    此时再修改php-fpm.conf 将user group都修改成root(经过上面的修改php-fpm已经支持root了)。

    重启php-fpm.

    配置各nginx.conf:

    location ~ .*\\.(php|php5)?$

    #fastcgi_pass unix:/tmp/php-cgi.sock;

    fastcgi_pass 127.0.0.1:9000;

    fastcgi_index index.php;

    include fcgi.conf;

    点到即止,不再多说。。。

建议继续学习:

QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK