PHP文件下载(源代码),而不是运行Nginx和PHP5-FPM

浏览到网站上的页面时,正在下载页面而不是运行Nginx Config –

user www-data www-data; worker_processes 4; events { worker_connections 2048; } http { include mime.types; default_type application/octet-stream; access_log off; sendfile on; tcp_nopush on; tcp_nodelay off; keepalive_timeout 10; gzip on; gzip_comp_level 2; gzip_proxied any; gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; server { listen 80; server_name localhost; location / { root /home/bil/public_html/webiste.net/public/; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } include /usr/local/nginx/sites-enabled/*; } 

虚拟网站configuration –

 server { listen 80; server_name localhost; rewrite ^/(.*) http://webiste.net/$1 permanent; } server { listen 80; server_name localhost; access_log /home/bil/public_html/webiste.net/log/access.log; error_log /home/bil/public_html/webiste.net/log/error.log; location / { root /home/bil/public_html/webiste.net/public/; index index.php index.html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; include /usr/local/nginx/conf/fastcgi_params; fastcgi_param SCRIPT_FILENAME /home/bil/public_html/webiste.net/public/$fastcgi_script_name; } }` 

我不认为你的server_name正在反映你想要做的事情。 configuration是好的,但所有三个“localhost”意味着第一个捕获。 第一个没有php位置。

用下面的replace你的重写规则

 rewrite ^/(.*) http://webiste.net/$1 last; 

我希望这会有所帮助,谢谢