欢迎光临
我们一直在努力

关于Nginx 13: Permission denied

关于Nginx 13: Permission denied

安装好nginx和php-fpm后出现403,404,502的错误 查找原因是说php-fpm没有启动 ,但在我实际中这个进程是启动的 找了半天没找到原因,查看nginx日志后 发现以下错误

2018/01/01 11:22:08 [crit] 2666#0: *1 stat() “/Volumes/macosxext/workspaces/hello/public/” failed (13: Permission denied), client: 127.0.0.1, server: hello.com, request: “GET / HTTP/1.1”, host: “hello.com”

 

2018/01/01 11:26:20 [error] 2720#0: *1 “/Volumes/macosxext/workspaces/hello/public/index.html” is forbidden (13: Permission denied), client: 127.0.0.1, server: hello.com, request: “GET / HTTP/1.1”, host: “hello.com”

 

2018/01/01 11:32:19 [crit] 2782#0: *1 connect() to unix:/tmp/php-cgi.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: hello.com, request: “GET /index.php HTTP/1.1”, upstream: “fastcgi://unix:/tmp/php-cgi.sock:”, host: “hello.com”

 

2018/01/01 11:40:50 [crit] 2918#0: *1 stat() “/Volumes/macosxext/workspaces/hello/public/” failed (13: Permission denied), client: 127.0.0.1, server: hello.com, request: “GET / HTTP/1.1”, host: “hello.com”

 

2018/01/01 11:42:04 [error] 2944#0: *1 FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream, client: 127.0.0.1, server: hello.com, request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:/usr/local/var/run/nginx/php-cgi.sock:”, host: “hello.com”

 

2018/01/01 21:50:11 [crit] 7172#0: *1 connect() to unix:/usr/local/var/run/nginx/php-cgi.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: hello.com, request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:/usr/local/var/run/nginx/php-cgi.sock:”, host: “hello.com”

遇到这种情况的解决办法

sudo chmod -R 0666 /Volumes/macosxext/workspaces/hello/public/

sudo chmod –R 0666 /usr/local/var/run/nginx/php-cgi.sock

sudo chown [所有者]:[分组] /usr/local/var/run/nginx/php-cgi.sock

修改Nginx fastcgi.conf 参数fastcgi_param

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

 

重启php-fpm,nginx

sudo pkill php-fpm

sudo ./php-fpm

sudo pkill nginx

sudo nginx

上文是小O开发环境遇到的情况,仅供参考.

关注婴儿健康成长

防撞条冬季鞋