# 일반적인 해결 방법
$ sudo vi /etc/nginx/nginx.conf
// 서비스 경로의 소유자 계정으로 변경하면 해결된다.
user nginx;
# SELinux 로 인한 접근 불가 인 경우
http://itzone.tistory.com/646
# 폴더에 그룹이 접근할 수 없는 경우
test 라는 계정에 /home/test/www 라는 경로를 서비스 경로 인경우…
// nginx 계정을 test 그룹에 포함한다.
$ sudo gpasswd -a nginx test
// 경로에 대한 권한 정보를 확인하면
$ namei -om /home/test/www
일반적으로 test 폴더는 drwx—— test test test 로 되어있어 계정이외에는 접근할 수 없게 되어있다. nginx 계정이 접근할 수 있게 수정한다.
$ sudo chmod 750 /home/test
https://stackoverflow.com/questions/6795350/nginx-403-forbidden-for-all-files
nginx php-fpm error #2
“Primary script unknown” while reading response header from upstream
php-fpm 에서 해당 경로의 php 페이지를 찾지 못하거나 권한이 없는 경우 오류가 발생한다.
1. php-fpm 소유권을 수정한다.
$ sudo vi /etc/php-fpm.d/www.conf
// 이전 포스팅을 참고하여 nginx 에 그룹권한을 준다
https://syakuis.tumblr.com/post/164513426884/nginx-error-is-forbidden-13-permission-denied
user = nginx
group = nginx
2. fastcgi_param 경로를 절대경로로 입력한다.
$ sudo vi /etc/nginx/conf.d/default.conf
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /home/www$fastcgi_script_name;
include fastcgi_params;
}
# php-fpm sock 을 사용할 경우
connect() to unix:/var/run/php-fpm/fpm-www.sock failed (13: Permission denied) while connecting to upstream
생성 된 소캣 파일을 읽지 못할때 오류가 발생한다.
$ namei -om /var/run/php-fpm/
f: /var/run/php-fpm/
dr-xr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root run
drwxr-xr-x root root php-fpm
$ sudo chown -R nginx.nginx /var/run/php-fpm/
접근할 수 있게 권한을 준다.
참고 : https://serverfault.com/questions/517190/nginx-1-fastcgi-sent-in-stderr-primary-script-unknown