1
我想在OSX(Mavericks)上設置django生產服務器。無法在osx上使用nginx + gunicorn查看靜態文件
這是我的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;
}
}
這是我所創建的系統上的用戶名爲WWW的數據,給了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/*;
}
的folllowing訪問權限:
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
我開始gunicorn沒有任何錯誤,所以是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/"
我試圖改變/用戶/你好/使用資產的權限須藤喬敦 - R的WWW-數據:www-數據資產,但它沒有幫助。 -R 777也沒有工作。
請建議我哪裏出錯了。謝謝!