nginx目录html 403,Nginx 403错误:禁止[文件夹]的目录索引

这篇博客讨论了在配置Laravel应用的Nginx服务器时遇到的问题,即访问后只显示‘糟糕,看起来出了问题。’的错误。作者提到,一种不安全的解决方法是将`app/storage`目录权限设置为777,但推荐的安全做法是改为755。文章还提到了配置文件的部分关键内容,包括URL路由和PHP处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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错误:“糟糕,看起来出了问题。”

一个可以解决这个问题的BAD IDEA将是chmod -R 777 app/storage(我在这里找到了:https://stackoverflow.com/a/18624752/470749)。但是,制作世界可写的东西是不好的安全措施。

我认为chmod -R 755 app/storage有效且更安全。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值