首页 > 解决方案 > Laravel nginx 路由在 localhost ubuntu 18.04 中不起作用

问题描述

我在我的本地系统 ubuntu 18.04 和 php 7.4 中安装了 nginx,当我运行其他站点时它可以正常工作但是当我尝试运行 laravel 站点时,它说找不到文件,任何人都可以帮我解决这个问题,下面是我的默认文件它存在于 /etc/ngix/sites-available

#
# Default server configuration
#
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.php$is_args$args;
    autoindex on;
        #try_files $uri $uri/ =404;
    }

  location ~ [^/]\.php(/|$) {
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

请任何人帮助我,我需要一个文件,我可以在其中运行所有 laravel 项目,就像我们在 apache 中一样。谢谢

标签: phpnginx

解决方案


推荐阅读