3
votes

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, e.g. 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?

1
Yay first Lumen question! :) I'm pretty sure you need to set root to /var/www/lumen/public - lukasgeiter
@lukasgeiter damn, how can I miss that? :) Please separate your comment to answer so I can accept it. Thank you! - Limon Monte

1 Answers

3
votes

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.