简体   繁体   English

Nginx加载索引文件时遇到麻烦

[英]nginx trouble loading index file

I have this nginx vhost file 我有这个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;
    }
}

(for domain trinityplex.com), but if I go to trinityplex.com nginx display me 502 Bad gateway and throws the index file - chrome download index.php like a normal download. (适用于域trinityplex.com),但是如果我转到trinityplex.com,nginx会向我显示502错误的网关,并抛出索引文件-像正常下载一样下载chrome下载index.php。

It's ridiculous I have never seen that. 我从未见过如此荒谬。 If I ask PHP for version it dumps 如果我问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

Have you any ideas how to fix that? 您有任何解决办法的想法吗?

Here is an nginx cofig file 这是一个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/*;

}

You haven't configured PHP in the server section so PHP files will obviously be sent as plain text. 您尚未在服务器部分中配置PHP,因此PHP文件显然将以纯文本格式发送。 How are you planning to run PHP? 您打算如何运行PHP? As FastCGI? 作为FastCGI?

Update: The configuration you have shown here does still not include anything at all about PHP or FastCGI. 更新:您在此处显示的配置仍然完全不包含有关PHP或FastCGI的任何内容。 Try something like this: 尝试这样的事情:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM