2013-06-21 2 views
0
다음 코드를 사용하여 시도

로 리디렉션 아니지만, 웹 사이트는 다시 기본 페이지에없는 서버에 404 오류 페이지Nginx에 404 페이지

server { 
     listen 80 default_server; 
     listen [::]:80 default_server ipv6only=on; 

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

     # Make site accessible from http://localhost/ 
     server_name localhost; 

     location/{ 
       # First attempt to serve request as file, then 
       # as directory, then fall back to displaying a 404. 
       try_files $uri $uri/ /404.html; 
       allow 192.168.1.127; 
       allow 127.0.0.1; 
       deny all; 
       # Uncomment to enable naxsi on this location 
       # include /etc/nginx/naxsi.rules 
     } 

     # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests 
     #location /RequestDenied { 
     #  proxy_pass http://127.0.0.1:8080; 
     #} 

     #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; 
     #} 

     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
     # 
     #location ~ \.php$ { 
     #  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; 
     #} 

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

새로운 브랜드로 재 지정, 모든 도움은 정말 감사합니다. 또한, 나는이 가이드를 다음했다 : http://arstechnica.com/gadgets/2012/11/how-to-set-up-a-safe-and-secure-web-server/

나는 당신을, 지금 당신은 설정에서 엔진을 취급 어떤 PHP가없는, 처음에 index.php을 가지고는 index 규칙을 변경 좋을 것 모든
+0

주석 처리 된 모든 행이 실제로 구성에 주석으로 추가 되었습니까? '기본 페이지'는 무엇입니까? 'index.php'와 같은 뜻입니까? –

+0

이 페이지의 대부분은 nginx를 설치했을 때 표준이 된 것입니다. 기본 페이지는 index.html이며 "Welcome to nginx!"라고 적혀 있습니다. – Username19

+0

fastcgi 또는 php-fpm이 있습니까? –

답변

0

우선 fastcgi 또는 fpm을 서버에 설치 했습니까?

변화

index index.html index.htm index.php; 

index index.php index.html; 

에있는 PHP 엔진을 결정한 후 당신은 내가 정상으로 PHP 엔진의 nginx없이 지금해야 서버 PHP는 주석을 제거 할 줄을 알 수있다 파일 중 하나를 브라우저에서 데이터를 인쇄하거나 PHP 파일을 다운로드하라는 메시지가 표시됩니다.

+0

나는 새로운 서버 설정에 익숙하며 솔직히 fastcgi 또는 fpm이 무엇인지 모르며 PHP를 구현하지 못했습니다. 내가 한 모든 설정은이 가이드에 따라 편지에 왔습니다 : http://arstechnica.com/gadgets/2012/11/how-to-set-up-a-safe-and-secure-web-server/ – Username19

+0

고정 : 그냥 nginx 새로 고침했다. – Username19