解決
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