centos + nginx + php + vsftp 实现不同路径

Fork Me On Github

centos + nginx + php + vsftp 实现不同路径

nginx 配置

具体配置请参考 【nginx 子目录匹配不同地方的文件夹

必须提升权限

nginx.conf

user root;

这样访问 vsftp 中的文件 html 或 js 是正常的

但访问 php 文件就会报 File not found 404 错误

开启 nginx 的 error_log 错误日志 会有一条这样的日志

FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream.

php-fpm 配置

此时应该提升 php-fpm 的权限

php-fpm.conf

user = root
group = root

但是启动 php-fpm 启动不了

please specify user and group other than root

不允许使用 root 权限,但她有一个启动参数 -R 允许使用 root

 /etc/init.d/php-fpm start -R

这样还是不行

找到 /etc/init.d/php-fpm 找到 start() 方法, 加上 -R 就行了

daemon --pidfile ${pidfile} /usr/local/php/sbin/php-fpm -R --daemonize

重启 /etc/init.d/php-fpm restart

再次访问php文件,正常了

Click here to view
0 141 0