流明nginx =错误500,在内部重定向到“ /index.php”时进行重写或内部重定向循环
作者:互联网
我正在尝试设置Lumen-建立在Laravel组件之上的“微框架”.在服务器端,有nginx php-fpm.
这是我的Nginx配置:
server {
server_name lumen.dev;
root /var/www/lumen;
location / {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_NAME /index.php;
fastcgi_param SCRIPT_FILENAME /var/www/lumen/public/index.php;
try_files $uri $uri/ /index.php?$query_string;
}
}
当我调用定义的路由时,此配置工作正常我看到“流明”.打开http://lumen.dev时响应.但是当我尝试打开未定义的路由(如http://lumen.dev/404)时,在浏览器中看到“ 500 Internal Server Error”,并且在nginx错误日志中显示以下消息:
rewrite or internal redirection cycle while internally redirecting to “/index.php”, client: 127.0.0.1, server: lumen.dev
如何修复nginx conf使其正常工作?
解决方法:
root选项必须指向公共目录:
server {
server_name lumen.dev;
root /var/www/lumen/public;
出现错误是因为它试图调用相对于根目录的/index.php?$query_string.因此,它试图在无尽的循环中查找/var/www/lumen/index.php.
标签:lumen,laravel,nginx,redirect,php 来源: https://codeday.me/bug/20191120/2044326.html