403在nginx/1.4.6上禁止(Ubuntu)-Laravel [英] 403 Forbidden on nginx/1.4.6 (Ubuntu) - Laravel

查看:159
本文介绍了403在nginx/1.4.6上禁止(Ubuntu)-Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断得到403 Forbidden

我的设置:

/etc/nginx/sites-available/default

默认

server {
        listen   80;


        root home/laravel-app/;

        index index.php index.html index.htm;

        server_name example.com;

        location / {
                try_files $uri $uri/ /index.html;
        }

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www;
        }

        # pass the PHP scripts to FastCGI server listening on the php-fpm socket
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;

        }

}


更新

我遵循了以下说明:关于此的任何提示/建议将是巨大的帮助!

Any hints/suggestions on this will be a huge help !

推荐答案

您需要为root指令指定绝对路径. Nginx使用在编译时使用--prefix开关设置的目录.默认情况下,这是/usr/local/nginx.

You need to specify an absolute path for your root directive. Nginx uses the directory set at compile time using the --prefix switch. By default this is /usr/local/nginx.

这意味着您的根(当前设置为根home/laravel-app/)使nginx在/usr/local/nginx/home/laravel-app/处查找文件,该文件可能不在您的文件中.

What this means is that your root, which is currently set to root home/laravel-app/ causes nginx to look for files at /usr/local/nginx/home/laravel-app/ which presumably isn't where your files are.

如果将root指令设置为诸如/var/www/laravel-app/public/的绝对路径,nginx将找到文件.

If you set your root directive to an absolute path such as /var/www/laravel-app/public/ nginx will find the files.

类似地,您会注意到我在上面的路径中添加了/public/.这是因为Laravel在其中存储index.php文件.如果您只想指向/laravel-app/,则没有索引文件,它将得到403.

Similarly you'll note that I added /public/ to the path above. This is because Laravel stores it's index.php file there. If you were to just point at /laravel-app/ there's no index file and it'd give you a 403.

这篇关于403在nginx/1.4.6上禁止(Ubuntu)-Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆