/
nginx php 연동
nginx php 연동
정리 필요
nginx 설치
php fpm 설치
php-fpm 설치(php fpm 설치 및 설정 참고)
nginx.conf
location ~ \.php$ { root html; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; }
/etc/php-fpm.d/www.conf
;listen = 127.0.0.1:9000 listen = '/var/run/php5-fpm.sock' listen.owner = nginx listen.group = nginx listen.mode = 0660 user = nginx group = nginx
service 구동
chkconfig php-fpm on chkconfig nginx on service php-fpm restart service nginx restart
문제 해결
다음 에러는 upstream 설정이 잘못되어 있을 경우 발생
[error] 2402#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 210.181.192.103, server: localhost, request: "GET /i.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host:
없는 폴더를 root 로 지정
root 로 지정된 public 의 상위 폴더인 awesome-prj 폴더가 없을 경우 위 에러 발생
root "/var/www/myapp/awesome-prj/public";
잘못된 upstream 설정 예 - SCRIPT_FILENAME
php 소스 경로가 /scripts 로 설정되어 있어서 $document_root 로 변경하여 해결
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
location 내 잘못된 root
"Unable to open primary script: /usr/share/nginx/html/a.php (No such file or directory)"
server { listen 80; server_name myhost; root /var/www/laravel/public; location ~ \.php$ { ## 아래 구문에서 root 를 덮어써서 발생 # root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
같이 보기
, multiple selections available,
Related content
PHP igbinary library 설치
PHP igbinary library 설치
More like this
nginx 로드 밸런싱 설정 (load balancing)
nginx 로드 밸런싱 설정 (load balancing)
More like this
RHEL/CentOS, Windows에 PHP apc 설치
RHEL/CentOS, Windows에 PHP apc 설치
More like this
php 가 session 디렉터리에 쓰지 못할 때
php 가 session 디렉터리에 쓰지 못할 때
More like this
RHEL/CentOS 와 Amazon Linux 에 php 7 설치
RHEL/CentOS 와 Amazon Linux 에 php 7 설치
More like this
nginx 업로드 파일 용량 초과 오류 해결 - HTTP 413 client intended to send too large body
nginx 업로드 파일 용량 초과 오류 해결 - HTTP 413 client intended to send too large body
More like this