nginx之常见错误

  在此只介绍源码安装nginx的时候,发生的一些常见的错误

1. nginx访问出现File not found

  1) php-fpm找不到SCRIPT_FILENAME中执行的PHP文件

更改配置文件nginx.conf 
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 
替换成下面

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

然后重新加载nginx配置文件 
/etc/init.d/nginx reload

  2) php-fpm不能访问执行的PHP,权限问题

两种解决方法: 
第一种,就是把你root文件夹设为其他用户允许 
第二种,找到你的php-fpm的配置文件,找到下面这段,把apache替换成你要的用户组

; RPM: apache Choosed to be able to access some dir as httpd 
user = apache 
; RPM: Keep a group allowed to write in log dir. 
group = apache

2. [emerg]: getpwnam(“nginx”) failed

  没有安装nginx用户导致无法启动

useradd -s /sbin/nologin -M nginx

id nginx
原文地址:https://www.cnblogs.com/xingxia/p/nginx_errors.html