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

Fork Me On Github
zodream 编程技术 2019年12月

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

nginx 配置

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

必须提升权限

nginx.conf

conf
 
user root;
1

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

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

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

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

php-fpm 配置

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

php-fpm.conf

conf
  
user = root
group = root
12

但是启动 php-fpm 启动不了

 
please specify user and group other than root
1

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

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

这样还是不行

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

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

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

再次访问php文件,正常了

点击查看全文
0 155 0