Nginx: stat() failed (13: permission denied)
解决
server {
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
#root /var/www/html;
# 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
root /root/test/dist;
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.html;
}
……
}
首先确定将 root
指定的目录权限改为 775
chmod -R 775 /root/test/dist;
然后将 nginx.conf
文件的 user 设置为 root
如果你想用默认的 www-data
用户,需要将 www-data
添加到 username
组中:
gpasswd -a www-data username
确保 username
组可以沿着路径输入所有目录:
chmod g+x /root && chmod g+x /root/test/dist
运行 stat
看看是否成功:
sudo -u www-data stat /root/test/dist
检查 nginx 配置
nginx -t
重启 nginx
nginx -s reload
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
2021-05-28 go map fatal error: concurrent map iteration and map write 读写锁与深度拷贝的坑
2021-05-28 vue 判断某个时间小于当前时间
2021-05-28 elmentui input number 数字验证
2019-05-28 HTTP与HTTPS的区别