我在使用默认配置的同时,在我的ubuntu 12.04机器上安装了nginx,并添加了特定目录。
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
root /username/test/static;
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
...
...
}
我只想要一个简单的静态nginx服务器,用于从那个目录中提供文件服务。但是,通过检查error.log
,我发现
2014/09/10 16:55:16 [crit] 10808#0: *2 stat() "/username/test/static/index.html" failed (13: Permission denied), client:, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "domain"
2014/09/10 16:55:16 [error] 10808#0: *2 rewrite or internal redirection cycle while internally redirecting to "/index.html
我已经在/username/test/static
上执行了chown -R www-data:www-data
,并将其设置为chmod 755
。我不知道还需要设置什么。
www-data
用户是否可以进入/username/test/static
目录:sudo -u www-data cd /username/test/static
。 - Maciej Sz