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; } } 

更新

我遵循这个指示: 在这里


任何提示/build议,这将是一个巨大的帮助!

你需要为你的root指令指定一个绝对路径。 Nginx使用编译时使用–prefix开关设置的目录。 默认情况下是/usr/local/nginx

这意味着你的根目前设置为根目录home/laravel-app/会导致nginx在/usr/local/nginx/home/laravel-app/中查找文件,这大概不在你的文件所在的位置。

如果你设置你的root指令为绝对路径,例如/var/www/laravel-app/public/ nginx将会找到这些文件。

同样,你会注意到我添加/public/上面的路径。 这是因为Laravel在那里存储index.php文件。 如果你只是指向/laravel-app/没有索引文件,它会给你一个403。

你需要有一个PHP文件的规则(在默认文件)

 # pass the PHP scripts to FastCGI server listening on (...) # location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # With php5-cgi alone: #fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } 

您在更新中添加的错误表明nginx正在从您的ssc-portal文件夹尝试一个目录索引。 由于您似乎在使用基本的nginx安装,因此目录索引在这里将失败的唯一原因是nginx无法找到列出的索引选项。

在你的服务器块中,你要告诉nginx在请求一个目录列表(以一个尾部的斜线结尾的URI)时依次尝试以下位置:index.php,index.html,然后是index.htm。

如果没有找到这些文件,则目录索引请求失败。

我最好的猜测是你有你的index.php文件在错误的地方。 你是否从ssc-portal文件夹中移动它?