微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – nginx加载索引文件时出错

我有这个Nginx vhost文件

server { # PHP/fastcgi
    listen       80;
    server_name  trinityplex.com www.trinity.com;
    access_log   /home/web/trinity_web/log/access.log;
    root /home/web/trinity_web/public;

    location / {
      index    index.html index.htm index.PHP;
    }
}

(对于域trinityplex.com),但是如果我去trinityplex.com Nginx显示502 Bad gateway并抛出索引文件 – chrome下载index.PHP就像正常下载一样.

这是荒谬的,我从未见过.如果我问PHP版本它转储

PHP 5.3.5-0.dotdeb.0 with Suhosin-Patch (cli) (built: Jan  7 2011 00:30:52) 
copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, copyright (c) 1998-2010 Zend Technologies
    with Suhosin v0.9.32.1, copyright (c) 2007-2010, by SektionEins GmbH

你有任何想法如何解决这个问题?

这是一个Nginx cofig文件

user root;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;
    server_names_hash_bucket_size 128;

    gzip  on;

    include /usr/local/Nginx/sites-enabled/*;

}

解决方法:

您尚未在服务器部分配置PHP,因此PHP文件显然将以纯文本形式发送.你打算如何运行PHP?作为FastCGI?

更新:您在此处显示的配置仍未包含任何有关PHP或FastCGI的内容.尝试这样的事情:

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ .PHP${
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_index  index.PHP;
                include        fastcgi_params;
        }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐