Laravel显示了'索引/'页面


Laravel shows me 'index of /' page

所以,我想弄清楚Laravel。我将其安装在Nginx服务器上并更改了配置文件-我将其粘贴在下面。但是,当我访问url时,它显示了一个Index of /页面,如下所示:https://i.stack.imgur.com/G1sQo.jpg

server {
    server_name website.com www.website.com;
    root /var/www/website.com/htdocs/;
    index index.php index.html;
    #browse folders if no index file
        autoindex on; 
    # serve static files directly
    location ~* '.(jpg|jpeg|gif|css|png|js|ico|html)$ {
        access_log off;
        expires max;
    }
    # removes trailing slashes (prevents SEO duplicate content issues)
    if (!-d $request_filename)
    {
        rewrite ^/(.+)/$ /$1 permanent;
    }
    # enforce NO www
    if ($host ~* ^www'.(.*))
    {
        set $host_without_www $1;
        rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
    }

    # canonicalize codeigniter url end points
    # if your default controller is something other than "welcome" you should change the following
    if ($request_uri ~* ^(/lobby(/index)?|/index(.php)?)/?$)
    {
        rewrite ^(.*)$ / permanent;
    }
    # removes trailing "index" from all controllers
    if ($request_uri ~* index/?$)
    {
        rewrite ^/(.*)/index/?$ /$1 permanent;
    }
    # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
    if (!-e $request_filename)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }
    # catch all
    error_page 404 /index.php;
        location ~ '.php$ {
        try_files $uri =404;
                fastcgi_pass  unix:/tmp/php.socket;
                fastcgi_index index.php;
                #include fastcgi_params;
                include /etc/nginx/fastcgi_params;
        }
}

我没有使用nginx,但是根据你的截图,看起来你的web根文件夹设置不正确。如果我正确阅读配置文件,你已经将你的web根设置为

/var/www/website.com/htdocs/

当你想把它设置为

/var/www/website.com/htdocs/public

也就是说,与常规Laravel应用程序一起发布的public文件夹应该是web服务器看到的文件夹。其他文件夹应该而不是是web可访问的。

@User183849481

将nginx配置文件中的fastcgi_pass unix:/tmp/php.socket;更改为fastcgi_pass 127.0.0.1:9000;。这将解决你的问题,因为nginx web服务器不能传递请求到php处理器。它显示黑屏。