구성 PHP를 실행할 수 없습니다.

구성 PHP를 실행할 수 없습니다.

nginx1.13.1 및 php7.0.18을 설치했으며 웹 사이트 서버에서 구성 PHP 페이지를 실행하려고 시도했지만 404 찾을 수 없음 오류가 발생합니다. 구성하는 방법을 알려주세요.

Nginx 구성( /etc/nginx/conf.d/*.conf )은 다음과 같습니다.

server {
    listen       80;
    server_name example.com;

   # charset koi8-r;   
   # access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index index.php index.html index.htm;

    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
     location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
     #   fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    } 
}

답변1

구성의 PHP 섹션에서 주석 처리한 줄과 줄이 PHP를 작동하게 만드는 요소 입니다 fastcgi_pass. fastcgi_index해당 줄의 주석 처리를 제거하고 nginx를 다시 시작하면 시스템의 PHP 소켓을 가리키도록 줄을 업데이트한 경우 작동이 시작됩니다 fastcgi_pass(적절한 경로는 PHP 구성 참조).

404에 대해서는 PHP 파일이 실제로 저장되는 위치 외부의 서버 구성을 참조 /var/log/nginx/error.log하고 설정했는지 확인 하십시오. 이 작업을 수행해야 NGINX가 파일을 찾을 위치를 알 수 있습니다.root

관련 정보