2017-03-16 2 views
1

내 nginx 서버에서 starnge 문제가 발생했습니다. 404 오류가 발생했지만 html 파일이 제대로 작동하는 하위 폴더 아래에 php 파일이 있습니다.PHP에서 Nginx : 하위 디렉토리에 던져진 404 오류

폴더 구조

html<folder> 
    index.php 

    test<folder> 
     test.php //not working 
     test.html //works fine 

Nginx의 구성

server { 
    listen  80 default_server; 
     listen  [::]:80 default_server; 
     server_name localhost; 
     root   /var/www/html; 

     # 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 /var/www/html$fastcgi_script_name; 
      include  fastcgi_params; 
     } 


}ml 

액세스 <ip-address>/test/test.html

액세스 <ip-address>/test/test.php 404 오류가 잘 작동한다.

액세스가 <ip-address> 일 때 잘 동작합니다 (html/index.php 파일을 가리킴).

html 폴더에 권한을 추가했으며, php.ini 파일에서 cgi.fix_pathinfo=0도 사용할 수 있습니다.

+0

아마도 https://serverfault.com/에 더 적합 할 수 있습니다. – jhmckimm

답변

1
server { 
    listen 80; 
    server_name localhost; 
    root /var/www/html; 
    autoindex on; 

    location/{ 
    index index.php index.html; 
    } 

    location ~\.php$ { 
    include fastcgi_params; 
    fastcgi_pass unix:/var/run/php5-fpm.sock; 
    fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    try_files $uri $uri/ /index.php; 
    } 
} 
+0

작동하지 않았 음 :) – Jabaa

+0

여기 error.log' "/var/www/html/50x.html"의 오류입니다 (2 : 해당 파일이나 디렉토리가 없습니다). – Jabaa

+0

당신은'php '파일 또는'html' 파일? –

관련 문제