我已经在Ubuntu 14.04服务器上创build了一个新的nginx和php5-fpm安装,并进行了如下所示的更改,以便configuration工作。 当我浏览到包含index.php的目录或尝试浏览到phpinfo.php文件时,浏览器尝试下载文件(即PHP不处理文件并返回响应)。
如果我浏览到任何其他的PHP文件,如process.php或test.php它运行良好。
更新/etc/php5/fpm/pool.d/www.conf来侦听TCP套接字
listen = 127.0.0.1:9000
文件:/etc/nginx/nginx.conf
user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; 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"; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
文件:/ etc / nginx / sites-available / default
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /home/user/www; index index.php index.html index.htm; autoindex on; server_name _; 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; } location ~ \.php$ { # Try a document root root /home/user/www # try_files $uri =404; #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; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
当错误(下载而不是进程页面发生)没有显示
当tail -f日志文件时:
/var/log/php5-fpm.log /var/log/nginx/error.log /var/log/nginx/access.log 这个configuration有什么问题?
您的location ~ \.php$具有root /home/user/www ,这是不必要的,因为在服务器级别上已经定义了相同的root 。 该定义也错过了分号。
所以,删除额外的root定义,看看是否有帮助。
尝试把移动线
include fastcgi_params;
从最后到第一个在块
location ~ \.php$ {
因为它会重新加载默认参数,所以你的自定义参数将被replace