简体   繁体   中英

Laradock 404 not found nginx

I'm trying to set up Laradock for my Laravel projects. I started with a new laravel project just to test things before trying with my current projects. I followed the tutorial but somewhere during the steps I must have messed something up I think because when I surf to the URL I get a "404 not found nginx". Someone experienced this before or knows what might be wrong? Thanks in advance!

404 error in browser

My example.conf in /var/wwwlaradock/nginx/sites

server {

listen 80;
listen [::]:80;

server_name example.local;
root /var/www/example/public;
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_buffers 16 16k;
    fastcgi_buffer_size 32k;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~ /\.ht {
    deny all;
}

location /.well-known/acme-challenge/ {
    root /var/www/letsencrypt/;
    log_not_found off;
}

error_log /var/log/nginx/laravel_error.log;
access_log /var/log/nginx/laravel_access.log;
}

My hosts file

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost
127.0.0.1   example.local

The name of my laravel project is "example" and is located in /var/www

I had the same problem.

The issue was in my mistake in parameter "root" in nginx's [your-name].conf file.

It should match the path shown when you log in the laradock "workspace" (with "docker-compose exec workspace bash"), eg "/var/www".

In your case it looks like should be string

root /var/www/public

instead of

root /var/www/example/public

The error occured because of invalid naming in laradock/nginx/sites/

before: laradock/nginx/sites/domain.laravel

after: laradock/nginx/sites/domain.laravel.conf

worked for me!

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM