FastCGI上的PHP(通过Plesk)为所有不以.php结尾的内容提供404

时间:2014-12-01 01:41:10

标签: php apache nginx fastcgi plesk

我刚刚将PHP切换为从Apache运行到FastCGI(通过Plesk)。现在,我尝试在我的域上访问的每个文件都不是php文件(如css,images,html ...),这样会产生404。

知道它可能是什么?

vhost特定配置文件(/etc/nginx/plesk.conf.d/vhosts/mysite.com.conf):

#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

server {
    listen 99.99.99.99:443 ssl;

    server_name mysite.com;
    server_name www.mysite.com;
    server_name ipv4.mysite.com;

    ssl_certificate             /usr/local/psa/var/certificates/certEbk3rnT;
    ssl_certificate_key         /usr/local/psa/var/certificates/certEbk3rnT;
    ssl_session_timeout         5m;

    ssl_protocols               SSLv2 SSLv3 TLSv1;
    ssl_ciphers                 HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;

    client_max_body_size 128m;

    root "/var/www/vhosts/mysite.com/httpdocs";
    access_log "/var/www/vhosts/system/mysite.com/logs/proxy_access_ssl_log";
    error_log "/var/www/vhosts/system/mysite.com/logs/proxy_error_log";

    location / {
        proxy_pass https://99.99.99.99:7081;
        proxy_set_header Host             $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header X-Accel-Internal /internal-nginx-static-location;
        access_log off;
    }

    location /internal-nginx-static-location/ {
        alias /var/www/vhosts/mysite.com/httpdocs/;
        add_header X-Powered-By PleskLin;
        internal;
    }

}

server {
    listen 50.23.99.2:80;

    server_name mysite.com;
    server_name www.mysite.com;
    server_name ipv4.mysite.com;

    client_max_body_size 128m;

    root "/var/www/vhosts/mysite.com/httpdocs";
    access_log "/var/www/vhosts/system/mysite.com/logs/proxy_access_log";
    error_log "/var/www/vhosts/system/mysite.com/logs/proxy_error_log";

    location / {
        proxy_pass http://99.99.99.99:7080;
        proxy_set_header Host             $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header X-Accel-Internal /internal-nginx-static-location;
        access_log off;
    }

    location /internal-nginx-static-location/ {
        alias /var/www/vhosts/mysite.com/httpdocs/;
        add_header X-Powered-By PleskLin;
        internal;
    }

}

1 个答案:

答案 0 :(得分:1)

* .php文件的请求正常工作,因为nginx透明地将它与apache相关联,这是由适当的apache vhost捕获的。

静态文件获得404因为:

  1. nginx无法找到正确的nginx vhost,默认情况下请求被阻止vhost
  2. 还有一些nginx vhost可以捕获所有请求(例如,通配符子域* .mysite.com)。
  3. 这里没有任何有用的建议,只需修改你所有的nginx配置。