I'm trying to setup Lumen - "micro-framework" built on top of Laravel's components. On server-side there's nginx + php-fpm.
Here's my nginx config:
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;
}
}
This config work fine when I'm calling defined route, eg I see "Lumen." response when opening http://lumen.dev . But when I try to open undefined route like http://lumen.dev/404 I see "500 Internal Server Error" in browser and this message in nginx error log:
rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 127.0.0.1, server: lumen.dev
How can I fix my nginx conf to make it working?
The root
option has to point to the public directory:
server {
server_name lumen.dev;
root /var/www/lumen/public;
The error appears because it's trying to call /index.php?$query_string
which is relative to the root. So it tries to find /var/www/lumen/index.php
in an endless loop.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.