2012-02-18 6 views
2

내 nginx를 설정했지만 가상 호스트의 모든 * .php 파일에 500 개의 내부 서버 오류가 반환됩니다.nginx 및 apache (php)

server { 
listen tucnak.dev:80; ## listen for ipv4; this line is default and implied 

root /home/tucnak/Web/Lab; 
index index.php index.html; 

server_name tucnak.dev; 

location/{ 
    # First attempt to serve request as file, then 
    # as directory, then fall back to index.html 
    try_files $uri $uri/ /index.html; 
} 

location /doc { 
    root /usr/share; 
    autoindex on; 
    allow 127.0.0.1; 
    deny all; 
} 

location /images { 
    root /usr/share; 
    autoindex off; 
} 

#error_page 404 /404.html; 

error_page 500 502 503 504 /50x.html; 
location = /50x.html { 
    root /usr/share/nginx/www; 
} 

location ~ \.php$ { 
    proxy_pass http://127.0.0.1; 
} 

location ~ \.php$ { 
     set $php_root /home/tucnak/Web/Lab; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name; 
     include /etc/nginx/fastcgi_params; 
    } 

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

어디에서 오류가 있습니까? 내 PHP 파일이 정확합니다!

<?php echo("Hello!"); ?> 

저는 정말 nginx에서 새로운 기능으로 도움이 필요합니다. apache2 이후 - 혼란스러워!

UPD : nginx가 성공적으로 아파치에 대한 쿼리를 제공하지 않는다고 생각합니다. 나는 그것을 고치는 법을 모른다.

+1

왜 'proxy_pass'와 'fastcgi_pass'를 모두 사용하고 있습니까? – Rifat

+0

그 (proxy_pass)없이 그는 .php 파일을 다운로드 할 것을 제안합니다.) – tucnak

+1

~ 위치 중 하나를 제거해야 할 수도 있습니다 ~ \ .php $ 그것은 분명하지 않습니다, 당신은 아파치 백엔드 또는 fastcgi를 사용하고 있습니다. nginx 나는 그것을 해결할 수 없다고 생각합니다 – ykhrustalev

답변

1

내가 봤던 배포판에 대한 모든 자습서를 검색하고 테스트 해봤는데 아무도 작동하지 않았습니다. 그래서 저는 배포자를 위해 올바른 문서를 참고해야한다는 것을 배웠습니다. 그렇지 않으면 간단히 작동하지 않을 것입니다. 그래서 찾았습니다 this one

Apache 2.2를 실행하는 RHE5.7 Tikanga가 있습니다. 두 개의 사이트가 8080 포트와 nginx-1.0.14-1.el5.ngx 80에서 실행 중입니다. 두 개의 디렉토리가/var/www/html/site1 및/var/www/html/site2에 smlinking되어 있습니다. PHP는 레드햇 사이트 관리자에 사람들을 위해 5

에서 모두,이 날

  1. 편집하여 http.conf에 근무하고 8080
  2. 들어 사이트의 지시에 따라 accordinglly nginx.conf 개정을 변경합니다.
  3. 개정 가상 호스트는 그것이하여 http.conf으로 포함 할 수 /etc/httpd/conf.d/httpd-vhosts.conf 또는 기타 너무 오래 파일을 다음과 같이 지시어를 포함 :

$하여 NameVirtualHost * : 8080 -

<VirtualHost *:8080> 
    ServerAdmin [email protected] 
    ServerName localhost 
    DocumentRoot /var/www/html/ 
</VirtualHost> 

<VirtualHost *:8080> 
    ServerAdmin [email protected] 
    ServerName site1 
    DocumentRoot /var/www/html/site1 
</VirtualHost> 

<VirtualHost *:8080> 
    ServerAdmin [email protected] 
    ServerName site2 
    DocumentRoot /var/www/html/site2 
</VirtualHost>` 

/etc/nginx/nginx.conf이 파일의 상단에 개정 :

..... $worker_rlimit_nofile 20480; ....

gzip_buffers 32 8k; 
    gzip_comp_level 6; 
    gzip_http_version 1.0; 
    gzip_min_length 1; 

줄 #include /etc/nginx/conf.d/*.conf는 내게 쓸모 없기 때문에 주석 처리되었습니다.) 모든 남아 코드는 불변하지만 내 IP서버 이름, 내가 호스트 이름를 넣어이 경우, 루트 명령의 것과 다른 동일한 루트는/usr/share /의 nginx/html로 남아 가상 conf 파일/var/www/html /. 내 생각 엔 프론트 엔드로서 nginx는 아파치가 제공되는 웹 파일이 어디에 있는지 알지 못한다.

내가 어떤 브라우저 종류로 이동 :

IP는 nginx를 기본 페이지를 보여줍니다, 그래서는 80 포트를 듣고 추측; ip/site1은 site1을 표시합니다. ip/site2는 site2를 표시합니다.

다른 포트는 있지만 80 또는 8080 디스플레이 연결 오류가 발생합니다.

안부.