解决
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
标签:index,stat,dist,nginx,permission,www,server,failed,root
From: https://www.cnblogs.com/niuben/p/18217161