【发布时间】:2018-03-28 13:32:57
【问题描述】:
我是 Nginx 的新手,刚刚开始在 Windows 上尝试使用 WinNMP 我已经成功安装并且可以使用基本的 PHP。然后我继续尝试 Laravel 5.5。使用 composer 安装似乎成功,它给出了 laravel 错误页面:
我用来调用这个页面的url是http://localhost/mylaraveltest/public/
我检查了 Laravel 错误日志文件,但那里没有错误消息。然后我检查了来自 Nginx 的错误消息并看到了这个:
2018/03/28 11:30:20 [warn] 8560#11828: *21 upstream server temporarily disabled while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /mylaraveltest/public/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9003", host: "localhost"
2018/03/28 11:30:20 [error] 8560#11828: *21 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /mylaraveltest/public/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9003", host: "localhost"
好像是路由问题。从official page看来,我应该添加以下内容:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
问题是,它没有提到我应该把这条线放在哪里……而且似乎很明显,我在谷歌找到的所有指南都只关注要添加的内容,但没有提到在哪里添加添加这一行。
我猜测了一下,放到nginx.conf的server括号里面,但是问题依旧。如果这是错误的添加位置,应该放在哪里?如果这是正确的地方,那么还有什么可能导致问题?
【问题讨论】:
-
你可以试试这个吗? try_files $uri $uri/ /index.php$is_args$args;
-
首先,我添加的try_files相关设置是否正确?
-
我猜 laravel 工作正常。你能显示你的路线吗
-
我用这个
try_files $uri $uri/ /index.php$is_args$args; -
我的意思是,我应该在哪里添加这一行?
标签: php laravel nginx laravel-5 laravel-5.5