Lumen 5.4 routes not working on nginx 1.12.1

Chux Anyirah posted 1 year ago

The issue is that apart from the '/' route, no other route works.. e.g routes like '/test' throws 404 error. I have googled and tired every suggestion, still no solution. I'll appreciate any suggestions.

Here is my nginx.conf

server {
        listen       80;
        #listen       [::]:80 default_server;
        server_name  18....my_ip;
        #root         /usr/share/nginx/html;
        root /var/www/html/dev;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

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

        location ~ \.php$ {
                try_files $uri $uri/ /index.php?$query_string;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_par

Here is the route i'm trying to access

$app->get('/test', function () use ($app) {
    return response()->json(['response'=>['status' => true, 'msg' => 'Great!', 'data' => []]]);
andresnijder replied 1 year ago

What's the location of your index.php? Is it /var/www/html/dev? Make sure root points to your public directory

Chux Anyirah replied 1 year ago


I have tried using /var/www/html/dev/public as the root, same issue. Besides, I can access the home page using http://my_ip_address/public even when the root is pointed to /var/www/html/dev but the issue is other routes like http://my_ip_address/public/foo do not work whether or not I attach public to root or use it in the url

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us