Laravel on nginx显示403,但我的路径是正确的

时间:2017-09-29 14:06:35

标签: php laravel nginx

我有一个digitalocean Droplet,我想运行一个laravel项目。我使用了本教程https://www.digitalocean.com/community/tutorials/how-to-deploy-a-laravel-application-with-nginx-on-ubuntu-16-04

问题是它显示403.我在其他问题上看到他们错过了公共目录或他们的路径错了,但在我的情况下,当我的公共目录正确时,我得到403,而当我错了。

我的nginx错误日志说

2017/09/29 13:58:16 [error] 15176#15176: *2 directory index of "/var/www/laravel/public/" is forbidden

我的nginx sites-available / my-site.com

server {
        listen 80;
        listen [::]:80;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/laravel/public;

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

        server_name my-site.com www.my-site.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?$query_string;
        }

2 个答案:

答案 0 :(得分:3)

答案就在你的nginx配置中。它也链接到教程中。

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

您尚未添加index.php。

答案 1 :(得分:0)

我在VestaCp上也遇到了同样的问题,但是,我做过的唯一真正的解决方案是禁用nginx服务器,只是让apache2像默认值一样,然后在配置中放开nginx防火墙,