Php Ubuntu 18.04 Laravel 5.7 nginx 1.14 Laravel路由不工作

Php Ubuntu 18.04 Laravel 5.7 nginx 1.14 Laravel路由不工作,php,laravel,nginx,Php,Laravel,Nginx,我最近将服务器从apache移到了nginx,在使用apache时,我有一个使用Laravel框架的工作站点 出于某种原因,除了基本索引页之外,没有其他页面只返回404错误。我确信这与我的nginx配置有关。我当前的配置如下所示 server { listen 80; server_name munkeemagic.munkeejuice.co.uk; root /var/www/html/munkeemagic/mtg-webby/mtg/public; i

我最近将服务器从apache移到了nginx,在使用apache时,我有一个使用Laravel框架的工作站点

出于某种原因,除了基本索引页之外,没有其他页面只返回404错误。我确信这与我的nginx配置有关。我当前的配置如下所示

server {
    listen 80;

    server_name munkeemagic.munkeejuice.co.uk;

    root /var/www/html/munkeemagic/mtg-webby/mtg/public;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$is_args$args;
    }

    location ~* \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}
我已检查以确保为用户nginx正在使用的用户www数据设置了所有文件权限。我甚至试过换衣服

location / {
    try_files $uri $uri/ /index.php?$is_args$args;
}

但这并没有产生任何影响,我仍然看到同样的问题

所以基本上,如果我导航到这个配置,页面就会显示出来

如果我去,我会得到一个404错误

有人知道我做错了什么吗

按照用户3647971的建议,我修改了配置,如下所示:

server {
listen 80;

server_name munkeemagic.munkeejuice.co.uk;

root /var/www/html/munkeemagic/mtg-webby/mtg/public;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";

index index.php index.html;

charset utf-8;

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

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

error_page 404 /index.php;

location ~* \.php$ {
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~ /\.(?!well-known).* {
    deny all;
}
}

我重新启动了nginx以进行更改,并清除了路由缓存,但不幸的是,我仍然有相同的问题。

好的,我解决了问题,但我有点愚蠢。我的默认配置覆盖了我的网站特定配置。我取消了默认配置的链接,重新启动了nginx,一切都开始正常工作。

好的,我解决了问题,但我有点愚蠢。我的默认配置覆盖了我的网站特定配置。我取消了默认配置的链接,重新启动了nginx,一切都正常运行。

您是否使用了laravel附带的默认nginx配置?嗯,我想我已经使用了,但刚刚在laravel网站上找到了默认配置。将对此进行一次尝试,看看这是否会有所不同。还可能需要使用
php artisan route:cache
:)清除路由缓存。希望它能有所帮助幸运的是,这两个提示没有帮助。我已经更新了我的问题,以反映我已经更改了配置。你是Laravel的根文件夹吗?你真的在那里定义了吗?看起来不是laravel标准吗?你使用laravel附带的默认nginx confs吗?嗯,我以为我有,但刚刚在laravel网站上找到了一个默认配置。将对此进行一次尝试,看看这是否会有所不同。还可能需要使用
php artisan route:cache
:)清除路由缓存。希望它能有所帮助幸运的是,这两个提示没有帮助。我已经更新了我的问题,以反映我已经更改了配置。你是Laravel的根文件夹吗?你真的在那里定义了吗?看起来不像拉威尔的标准
server {
listen 80;

server_name munkeemagic.munkeejuice.co.uk;

root /var/www/html/munkeemagic/mtg-webby/mtg/public;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";

index index.php index.html;

charset utf-8;

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

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

error_page 404 /index.php;

location ~* \.php$ {
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~ /\.(?!well-known).* {
    deny all;
}
}