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

下载 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/*;

    }

虚拟站点配置 -

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;
                        }

       }`

答案1

我认为您的 server_name 并未反映您想要执行的操作。配置很好,但所有三个“localhost”都表示第一个可用。第一个中没有 php 位置。

答案2

用以下内容替换您的重写规则

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

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

相关内容