Home » Php » php – File Not Found when running Laravel with Nginx using LaraDock

php – File Not Found when running Laravel with Nginx using LaraDock

Posted by: admin July 12, 2020 Leave a comment

Questions:

I am learning Laravel using its tutorial. I installed Laravel and the required stacks using LaraDock.

Nginx returns File not found when I go to the IP where the app is running. Below is my NGINX configuration.

server {
        root /var/www/laravel/public/;
        listen 80 default_server;

        listen [::]:80 default_server ipv6only=on;
        index index.php index.html index.htm;
        location / {
             try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
            try_files $uri /index.php =404;
            fastcgi_pass php-upstream;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
        location ~ /\.ht {
            deny all;
        }
}

This is the error from NGINX error log.

2016/08/19 08:53:06 [error] 47#47: *16 FastCGI sent in stderr:
“Primary script unknown” while reading response header from upstream,
client: 192.168.99.1, server: , request: “GET / HTTP/1.1”, upstream:
“fastcgi://111.13.0.5:9000”, host: “192.168.99.100”

How to&Answers:

To be sure you have index.php in /var/www/laravel/public/

run command
docker-compose exec nginx ls /var/www/laravel/public/

If you don’t have index.php in the folder, probably your project folder mounted wrong.

Did you edit .env, or docker-compose.yml file?

Where you put laradock folder relative to your project folder