我的nginx fastcgi配置下载php文件而不是执行它们

我在ubuntu 13.04上全新安装php5-fpm和nginx时使用此配置:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

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

    server_name localhost;

    location / {
            try_files $uri $uri/ /index.html;
    }

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

    error_page 404 /404.html;

    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:
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }
}

但是,我的网页浏览器将php视为文本而不是执行的结果.我应该在哪里寻找解决问题?
最佳答案
您的php代码正在被直接显示,因为它没有被发送到php引擎,这意味着位置块正在匹配并且php文件被提供,但php文件没有被php块捕获,所以你的问题在php块.

在该块中,您有2个fastcgi_pass,一个端口(9000),另一个连接到unix套接字,您不能同时使用,但是由于您已经用fastcgi标记了您的问题,所以我假设您正在使用fastcgi尝试评论这一行

#fastcgi_pass unix:/var/run/php5-fpm.sock;

dawei

【声明】:丽水站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。