Nginx Php 세팅 오류/ 502 BadGateway ([emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:58)
1. Ubuntu Nginx, Php5 세팅해주는 과정에서 오류가 발생
$sudo nano /etc/nginx/sites-available/default
.
.
...
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
이렇게 세팅을 해줬더니 502 Bad GateWay 오류가 났다.
로그를 찍어보니
$ nginx -t
nginx: [warn] server name "http://bobss.tk" has suspicious symbols in /etc/nginx/sites-enabled/default:28
nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:58
nginx: configuration file /etc/nginx/nginx.conf test failed
default파일에서 오류가 발생해서 검색해보니
" The location block provided results in error: nginx: [emerg] unknown directive "fast_cgi_split_path_info" in /etc/nginx/sites-enabled/default:56 Need to remove the underscore between fast and cgi: fastcgi_split_path_info ^(.+\.php)(/.+)$; "
Then comment the first case with php5-cgi alone since php5-fpm is already installed.
I came with the same problem. Hope this could help you.
.
.
...
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
php5-fpm와 cgi 가 중복된다는 뜻인것같아 주석처리후 재시작 했더니 해결