简体   繁体   English

Laradock 404 未找到 nginx

[英]Laradock 404 not found nginx

I'm trying to set up Laradock for my Laravel projects.我正在尝试为我的 Laravel 项目设置 Laradock。 I started with a new laravel project just to test things before trying with my current projects.我从一个新的 laravel 项目开始,只是为了在尝试我当前的项目之前进行测试。 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".我按照教程进行了操作,但是在执行步骤的某个地方,我认为我一定搞砸了,因为当我浏览 URL 时,我得到一个“404 not found nginx”。 Someone experienced this before or knows what might be wrong?有人以前经历过这种情况或知道可能出了什么问题吗? Thanks in advance!提前致谢!

404 error in browser浏览器出现404错误

My example.conf in /var/wwwlaradock/nginx/sites我在 /var/wwwlaradock/nginx/sites 中的 example.conf

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我的 laravel 项目的名称是“example”,位于/var/www

I had the same problem.我有同样的问题。

The issue was in my mistake in parameter "root" in nginx's [your-name].conf file.问题出在我在 nginx 的 [your-name].conf 文件中的参数“root”中的错误。

It should match the path shown when you log in the laradock "workspace" (with "docker-compose exec workspace bash"), eg "/var/www".它应该与您登录 laradock “workspace”(使用“docker-compose exec workspace bash”)时显示的路径匹配,例如“/var/www”。

In your case it looks like should be string在您的情况下,它看起来应该是字符串

root /var/www/public根 /var/www/public

instead of代替

root /var/www/example/public根 /var/www/example/public

The error occured because of invalid naming in laradock/nginx/sites/由于 laradock/nginx/sites/ 中的命名无效而发生错误

before: laradock/nginx/sites/domain.laravel

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

worked for me!为我工作!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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