nginx php-fpm一直在下载文件

虚拟主机:

server { listen *:8080; location / { root /var/www/default/pub; index index.php; # if file exists return it right away if (-f $request_filename) { break; } if (!-e $request_filename) { rewrite ^(.+)$ /index.php$1 last; break; } } # serve static files directly location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ { access_log off; expires max; } location ~* \.php$ { # By all means use a different server for the fcgi processes if you need to fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include /usr/local/nginx/conf/fastcgi_params; } location ~ /\.ht { deny all; } } 

http://192.168.135.128/index.php加载就好了…

http://192.168.135.128/public_/html/index.php下载…

你的虚拟主机工作正常(但端口8080):

 # curl localhost:8080/public_/html/index.php 123 

/var/www/default/pub/public_/html/index.php:

 <?php echo "123"; ?> 

发送php文件到fpm的位置块在你的服务器块之外(由于有一个额外的'}')….所以,当然,nginx不会把文件传递给php-fpm,而只是提供它按原样,这基本上是你描述的症状。

也就是说,你的configuration还有一些其他的问题,但与手头的问题无关。

 } location ~* \.php$ { 

删除'位置'上方的额外'}',看看是否能解决这个问题。