dongpai6567 2017-09-29 14:06
浏览 1272
已采纳

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

I have a digitalocean droplet and I want to run a laravel project. I used this tutorial https://www.digitalocean.com/community/tutorials/how-to-deploy-a-laravel-application-with-nginx-on-ubuntu-16-04

The thing is that it displays a 403. I saw on other questions that they missed the public directory or they had the path wrong, but in my case I got a 403 when I have the public dir correct, and a 500 when I have it wrong.

My nginx error log says

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

My 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;
        }
  • 写回答

1条回答 默认 最新

  • doudu8291 2017-09-30 09:50
    关注

    The answer is right there in your nginx config. It is also shown in the tutorial you link to.

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

    You have not added index.php.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R