2011-11-15 5 views
1

저는 NGINX에 비교적 익숙합니다. (24 시간 미만) 인정하지만, 기본적으로 구성되었습니다. 친구를위한 사이트를 만들고 있는데, 아래 코드에서와 같이 하위 도메인을 사용하는 코드의 예를 보았습니다. 그러나 하위 도메인에서는 PHP가 작동하지 않습니다. "subdomain.domain.tld"로 이동하면 파일을 다운로드하도록 요청하지만 "subdomain.domain.tld/index.php"로 이동하면 "입력 파일이 지정되지 않았습니다."라고 표시됩니다. 그런데 하위 도메인은 phpmyadmin입니다.NGINX Config PHP 문제

server { 
    listen 80; 
    server_name irc.physibots.info; 

    rewrite (.*)  http://physibots.info:3989; 
} 

server { 
    listen 80; 
    server_name "~^([a-z]+)?.physibots.info"; 

    root /home/virtual/physibots.info/subdomains/$1; 
    index index.php index.html index.html; 

    location/{ 
     autoindex on; 
    } 
    location ~ \.php { 
     try_files $uri /error.html 
     fastcgi_index index.php; 
     fastcgi_pass unix:/tmp/php.socket; 

     include fastcgi_params; 
     fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; 
     fastcgi_param PATH_INFO $fastcgi_path_info; 
     fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    } 
} 

#server { 
# listen   443; 
# server_name localhost; 
# 
# charset utf-8; 
# 
# ssl on; 
# ssl_certificate 

server { 
    listen  80; 
    server_name physibots.info default; 

    root   /home/virtual/physibots.info/public_html; 
     index index.php index.html index.html; 

    location/{ 
     autoindex on; 
    } 
    location ~ \.php { 
     try_files $uri /error.html 
     fastcgi_index index.php; 
     fastcgi_pass unix:/tmp/php.socket; 

     include fastcgi_params; 
      fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; 
     fastcgi_param PATH_INFO $fastcgi_path_info; 
     fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    } 
} 
+0

동일한 하위 도메인의 정적 파일에도 액세스하려고 했습니까? 정적 파일이 잘 제공된다면, fastcgi 설정에 문제가 있습니다. 그렇지 않다면 nginx config에 있습니다. :) – petermolnar

답변

2

이동 위치/{} 블록에 try_files 및 try_files $ URI $ URI//index.php로 변경;

location/{ 
     autoindex on; 
     try_files $uri $uri/ /index.php; 
    } 
    location ~ \.php { 
     fastcgi_index index.php; 
     fastcgi_pass unix:/tmp/php.socket; 

나머지는 초보자에게 놀랍도록 좋습니다. :)

또한 웹 브라우저가 아닌 컬 (curl)을 사용하여 테스트를하고 있는지 확인하십시오. 그렇지 않으면 계속 캐싱과 싸울 것입니다.

+0

고맙습니다!, 완전히 다른 문제가 있었지만 캐싱이 문제였습니다. 모두 따라와! :) 내 문제는 내 PHP 파일을 다운로드하는 것이 었습니다. 나는이 문제를 해결했지만 브라우저가 캐싱 중이기 때문에 PHP 파일을 계속 다운로드했다. 고마워요! –

+0

완벽한 답변,이게 정말 도움이되었습니다. – Joseph