【问题标题】:Laravel on nginx displays 403, but my path is correctnginx 上的 Laravel 显示 403,但我的路径是正确的
【发布时间】:2020-01-24 04:13:13
【问题描述】:

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

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

我的 nginx 错误日志显示

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

我的 nginx 站点-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;
        }

【问题讨论】:

  • 被禁止目录权限是否正确?像 775 什么的?
  • 是的,还有 chown -R www-data:www-data
  • 发布完整的 nginx 配置

标签: php laravel nginx


【解决方案1】:

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

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

你还没有添加 index.php。

【讨论】:

  • 是的!我在写完问题后找到了它:D 谢谢!!
【解决方案2】:

我对 VestaCp 也有同样的问题,但是,我唯一真正的解决方案是禁用 nginx 服务器,让 apache2 像默认值一样,并在配置中关闭 nginx 防火墙,

【讨论】:

    猜你喜欢
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多