2011-09-12 5 views
1

우분투 11에서 php-fpm (php v 5.3.5)을 사용하여 nginx를 구성하려고합니다. nginx 및 php5-fpm 모두 www- 데이터로 실행되도록 설정되어 있습니다. nginx는 html 파일을 제공하지만 php 파일은 제공되지 않습니다 (로그 파일은 404 오류를 생성 함). php5-fpm이 실행 중이고 nginx가 연결하려고하는 포트 (9000)에서 수신 대기 중입니다. 구성 파일은 아래에 복사됩니다. 파일은/var/www에 있습니다 (www-data에는 해당 디렉토리 내의 모든 파일에 대한 읽기/쓰기 권한이 있음).우분투의 nginx 및 php5-fpm 구성 지원

php5-fpm이 nginx로부터 요청을 제대로 수신하고 있는지 여부와 잘못된 권한/잘못된 설정 파일 위치로 인해 요청을 처리 할 수 ​​없는지 여부를 확인하려면이 문제를 해결할 수 있습니까?

도움을 주시면 감사하겠습니다.

nginx.conf 파일 : 사이트에

user www-data; 

    worker_processes 4; 

    pid /var/run/nginx.pid; 

events { 
    worker_connections 768; 

} 

http 

{ 

    include mime.types; 

    sendfile on; 

    tcp_nopush on; 

    tcp_nodelay on; 

    keepalive_timeout 65; 

    types_hash_max_size 2048; 

    # server_tokens off; 

    server_names_hash_bucket_size 64; 

    # server_name_in_redirect off; 

    include /etc/nginx/mime.types; 

    default_type application/octet-stream; 


    access_log /var/log/nginx/access.log; 
    error_log /var/log/nginx/error.log; 

    gzip on; 
    gzip_disable "msie6"; 
    gzip_comp_level 2; 
    gzip_proxied any; 
    gzip_http_version 1.1; 
    gzip_buffers 16 8k; 
    gzip_types text/plain text/css text/javascript application/json application/x-javascript text/xml application/xml application/xml+rss; 
    include /etc/nginx/conf.d/*.conf; 
    include /etc/nginx/sites-enabled/*; 
} 

기본 파일 (/ 사용 가능 사용 가능) 폴더 : nginx를 디렉토리에

default 

server 

{ 

    listen 80; 

    server_name localhost; 

    access_log /var/log/nginx/localhost.access.log; 

    location/{ 
     root /var/www; 

     index index.html index.php; 

     try_files $uri $uri/ /index.php?q=$uri&$args; 

    } 


    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ { 

     access_log  off; 

     expires   30d; 

     root /var/www; 

    } 



## Disable viewing .htaccess & .htpassword 
    location ~ /\.ht { 

     deny all; 

    } 

include php.conf; 

} 

php.config 파일 :

fastcgi_intercept_errors on; 


location ~ \.php$ 

{ 

    fastcgi_split_path_info ^(.+\.php)(/.+)$; 

    fastcgi_param PATH_INFO   $fastcgi_path_info; 

    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 

    fastcgi_param QUERY_STRING  $query_string; 

    fastcgi_param REQUEST_METHOD $request_method; 

    fastcgi_param CONTENT_TYPE  $content_type; 

    fastcgi_param CONTENT_LENGTH $content_length; 

    fastcgi_param SCRIPT_NAME  $fastcgi_script_name; 

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 

    fastcgi_param REQUEST_URI  $request_uri; 

    fastcgi_param DOCUMENT_URI  $document_uri; 

    fastcgi_param DOCUMENT_ROOT  /var/www; 

    fastcgi_param SERVER_PROTOCOL $server_protocol; 

    fastcgi_param GATEWAY_INTERFACE CGI/1.1; 

    fastcgi_param SERVER_SOFTWARE nginx; 

    fastcgi_param REMOTE_ADDR  $remote_addr; 

    fastcgi_param REMOTE_PORT  $remote_port; 

    fastcgi_param SERVER_ADDR  $server_addr; 

    fastcgi_param SERVER_PORT  $server_port; 

    fastcgi_param SERVER_NAME  $server_name; 

    fastcgi_read_timeout 600; # Set fairly high for debugging 

    fastcgi_pass 127.0.0.1:9000; 

    fastcgi_index index.php; 

} 
PHP5-FPM에 대한 16,

로그 파일 출력 : nginx를에서

configuration file /etc/php5/fpm/main.conf test is successful 

로그 파일 출력 :

"GET /index.php HTTP/1.1" 404 31 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1" 

답변

1

php5-fpm 이상의 PHP 파일을 전달하는 서버 블록에 약간의 기능이 없습니다.

location ~ .php$ { 
    include /etc/nginx/fastcgi_params; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name; 
} 

새 서버 블록 ( /site-enabled의 비트)를 작성하려면 this tool를 사용해보십시오.

+0

공유 해 주셔서 감사합니다. –