我有 3 个域名,正在尝试使用 Nginx 在一台服务器(Digital Ocean droplet)上托管所有 3 个站点。
mysite1.name mysite2.name mysite3.name
其中只有 1 个有效。其他两个导致 403 错误(以相同的方式)。
在我的 nginx 错误日志中,我看到:[error] 13108#0: *1 directory index of "/usr/share/nginx/mysite2.name/live/" is forbidden.
[error] 13108#0: *1 directory index of "/usr/share/nginx/mysite2.name/live/" is forbidden
我启用站点的配置是:
server { server_name www.mysite2.name; return 301 $scheme://mysite2.name$request_uri; } server { server_name mysite2.name; root /usr/share/nginx/mysite2.name/live/; index index.html index.htm index.php; location / { try_files $uri $uri/ /index.html index.php; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } }
所有 3 个站点都有几乎相同的配置文件。
每个站点的文件都位于 /usr/share/nginx/mysite1.name/someFolder 之类的文件夹中,然后 /usr/share/nginx/mysite1.name/live 是指向该文件夹的符号链接。(mysite2 和 mysite3 相同。)
server { server_name www.mysite2.name; return 301 $scheme://mysite2.name$request_uri; } server { #This config is based on https://github.com/daylerees/laravel-website-configs/blob/6db24701073dbe34d2d58fea3a3c6b3c0cd5685b/nginx.conf server_name mysite2.name; # The location of our project's public directory. root /usr/share/nginx/mysite2/live/public/; # Point index to the Laravel front controller. index index.php; location / { # URLs to attempt, including pretty ones. try_files $uri $uri/ /index.php?$query_string; } # Remove trailing slash to please routing system. if (!-d $request_filename) { rewrite ^/(.+)/$ /$1 permanent; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
然后浏览器中唯一的输出是一个 Laravel 错误:“哎呀,好像出了点问题。”
不要运行chmod -R 777app/storage。使某些东西在世界范围内可写是不好的安全性。
chmod -R 777app/storage
chmod -R 755 app/storage工作,更安全。
chmod -R 755 app/storage