【问题标题】:nginx 500 Internal Server Errornginx 500 内部服务器错误
【发布时间】:2014-04-12 18:22:14
【问题描述】:

当我访问 127.0.0.1:6789 时它工作正常,但是当我尝试访问 127.0.0.1:6789/busca.html?q=a 之类的东西时,我得到 500 Internal Server Error

这是我的 nginx 配置文件

server {

    listen   88;


    root /vagrant/rizqcursosonline/rizqcursosonline/frontend/wwwpublic;
    index index.php index.html index.htm;

    server_name example.com;

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

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
          root /vagrant/rizqcursosonline/rizqcursosonline/frontend/wwwpublic/;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
            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;

    }

}

nginx 日志错误

2014/04/12 18:16:32 [error] 4165#0: *5 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 10.0.2.2, server: example.com, request: "GET /busca.html?q=a HTTP/1.1", host: "127.0.0.1:6789", referrer: "http://127.0.0.1:6789/"

2014/04/12 18:16:32 [错误] 4165#0: *7 重写或内部重定向周期,同时内部重定向到“/index.html”,客户端:10.0.2.2,服务器:example.com,请求:“GET /favicon.ico HTTP/1.1”,主机:“127.0.0.1:6789”

【问题讨论】:

  • 你为什么监听 88 端口,却在 6789 端口访问你的站点?

标签: nginx


【解决方案1】:

而不是

try_files $uri $uri/ /index.html;

我用过

try_files $uri/ $uri /index.php?$query_string;

【讨论】:

    【解决方案2】:

    因为这个错误可能是你的主 web 根文件夹 index.html 不存在的原因,关键是当你将 conf 文件配置为 try_files $uri $uri/ /index.html; 时,第一个 NGNIX 将搜索 index.html 文件。

    【讨论】:

      猜你喜欢
      • 2015-03-09
      • 1970-01-01
      • 2015-06-11
      • 1970-01-01
      • 2014-08-27
      • 1970-01-01
      • 2021-03-04
      • 2016-09-05
      • 1970-01-01
      相关资源
      最近更新 更多