无法在OSX上使用nginx + Gunicorn查看静态文件



我正在尝试在OSX(Mavericks)上设置Django生产服务器。

这是我的nginx服务器配置文件:

server { 
    listen       80;
    server_name  localhost;
    error_log   /pathtoerrorlog;
    access_log  /pathtoaccesslog;
    # serve static files
    location ~ ^/static/  {
      root    /Users/Hello/assets;
      expires 30d;
    }
    # serve media files ~ ^
    location ~ ^/media/  {
      root    /Users/Hello/assets;
      expires 30d;
    }
    location / {
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Real-IP $remote_addr;    
      proxy_pass http://localhost:8000;
    }
  }

这是nginx.conf配置文件

user www-data;
worker_processes  4;
error_log   /var/log/nginx/error.log;
events {
    worker_connections  4092;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay on;
    keepalive_timeout  65;
    types_hash_max_size 2048;
    server_names_hash_bucket_size 64;
    gzip  on;
    gzip_disable "msie6";
    include /etc/nginx/sites-enabled/*;
}

我在系统上创建了一个名为www-data的用户,并给出了Folllow访问权限:

sudo chown -R www-data:www-data /usr/local/etc/nginx
sudo chown -R www-data:www-data /etc/nginx
sudo chown -R www-data:www-data /var/log/nginx

我启动了没有任何错误的枪支,也是如此。

也是如此。

在浏览器中,Localhost将我重定向到Django应用程序,但未显示静态媒体。正如我在nginx错误日志中看到的那样,这是一个示例错误(在所有静态内容中)。

2014/01/25 20:16:23 [error] 35068#0: *68 open()    "/Users/Hello/assets/static/css/base.css" failed (13: Permission denied), 
client: 127.0.0.1, server: localhost, request: "GET /static/css/base.css HTTP/1.1", host: "localhost", referrer: "http://localhost/" 

我尝试使用sudo chown -r www-data更改/用户/Hello/Assets的权限:www-data资产,但这无济于事。-r 777也不起作用。

请建议我出错的地方。谢谢!

事实证明,必须为/users/hello/hello/Assets的所有父目录授予阅读权限。因此,我将访问所有用户,Hello,Assets,而不仅仅是以前的资产访问。

相关文章是:

nginx 403禁止所有文件

http://nginxlibrary.com/403-forbidden-error/

最新更新