自己配置 lnmp 运行 Laravel 出现了 403 Forbidden?
第一次在ubuntu16.04.4 LTS上自己安装nginx、mysql、php,
php的版本:
ubuntu@VM-0-17-ubuntu:/etc/nginx/sites-available$ php -v
PHP 7.1.15-1+ubuntu16.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018 11:10:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.15-1+ubuntu16.04.1+deb.sury.org+2, Copyright (c) 1999-2018, by Zend Technologies
nginx版本:
ubuntu@VM-0-17-ubuntu:/etc/nginx/sites-available$ nginx -v
nginx version: nginx/1.10.3 (Ubuntu)
下面是/etc/nginx/sites-available/default
文件的内容的
server {
listen 80 default_server;
listen [::]:80 default_server;
#root /var/www/html;
root /home/ubuntu/Code/blog/public;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
这是laravel5.1的目录结构,storage和bootstrap/cache目录应该是可写:
这是/var/log/nginx/error.log
报的错:
2018/03/09 16:29:35 [error] 22528#22528: *3 directory index of "/home/ubuntu/Code/blog/public/" is forbidden, client: 112.80.38.102, server: _, request: "GET / HTTP/1.1", host: "119.27.182.170"
运行时报403错误。如果我修改了/etc/nginx/sites-available/default
中的root /home/ubuntu/Code/blog/public;
改成root /home/ubuntu/Code/index.php;
就没问题。
请问有没有大神知道哪里出错了??
index index.html index.htm index.nginx-debian.html;
改成
index index.php index.html index.htm index.nginx-debian.html;