1
我想在ubuntu 11上用php-fpm(php v 5.3.5)配置nginx .nginx和php5-fpm都設置爲以www數據的形式運行。 nginx似乎提供html文件,但php文件沒有被提供(日誌文件生成404錯誤)。 php5-fpm正在運行並監聽nginx正試圖連接的端口(9000)。配置文件複製如下。文件位於/ var/www(www-數據具有對該目錄內所有文件的讀/寫訪問權限)。在ubuntu上配置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:從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"
感謝您的分享 –