Nginx 下载文件而不是执行 php

Nginx 下载文件而不是执行 php

nginx 服务器正在下载 php 文件,而不是执行它们

我尝试了网上发布的每一个解决方案

大多数人对位置有疑问

但我的已经取消注释了

我的默认配置文件

server {
    #listen   80; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /usr/share/nginx/www;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name test.com;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ /index.html;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }

    location /doc/ {
            alias /usr/share/doc/;
            autoindex on;
            allow 127.0.0.1;
            deny all;
    }

    # Only for nginx-naxsi : process denied requests
    #location /RequestDenied {
            # For example, return an error code
            #return 418;
    #}

    error_page 404 /404.html;


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    location ~ \.php$ {
            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:
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #       deny all;
    #}
}

相关内容