2014-09-06 22 views
0

我用nginx和gunicorn託管了django。我得到以下錯誤。無法使用gunicorn運行nginx,在連接到上游時獲取權限被拒絕錯誤

# 1 connect() to 127.0.0.1:8001 failed (13: Permission denied) while connecting to upstream, client: 106.77.61.123, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8001/favicon.ico", host: "<domainname> 

[相同配置的工作我的本地CentOS的機器上]

但在VPS託管環境(VPS):

我用的CentOS-7的用戶名 「ftpuser1」( nginx.conf中的用戶名是「ftpuser1」)。

我正在使用用戶nginx的 「ftpuser1」

所有者的/ var /緩存/ nginx的是 「ftpuser1」 與777個權限源代碼路徑的遞歸

所有者也是 「ftpuser1」 與777個權限遞歸

這裏是我的/etc/nginx/conf.d/default.config配置文件的內容:

server { 
    listen  80; 
    server_name localhost; 

    #charset koi8-r; 
    #access_log /var/log/nginx/log/host.access.log main; 

    location/{ 
     root /home/ftpuser1/donation/templates; 
     index home.html; 
     proxy_pass http://127.0.0.1:8001; 
    } 

    #error_page 404    /404.html; 

    # redirect server error pages to the static page /50x.html 
    # 
    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root /usr/share/nginx/html; 
    } 

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80 
    # 
    #location ~ \.php$ { 
    # proxy_pass http://127.0.0.1; 
    #} 

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
    # 
    #location ~ \.php$ { 
    # root   html; 
    # fastcgi_pass 127.0.0.1:9000; 
    # fastcgi_index index.php; 
    # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 
    # include  fastcgi_params; 
    #} 

    # deny access to .htaccess files, if Apache's document root 
    # concurs with nginx's one 
    # 
    #location ~ /\.ht { 
    # deny all; 
    #} } 

誰能幫我在這?

+0

檢查是否有任何其他內容正在使用'netstat -tulpn | grep 8001' – 2014-09-06 14:05:09

回答

0

這個錯誤信息的意思是,如果你在linux環境下,你沒有閱讀+寫入權限到服務「favicon.ico」的根文件夾;

試試這個命令:sudo chmod 775 /<foldername>

不要忘了sudo在你的命令的開頭。

那麼你應用的權限嘗試重新啓動您的* nginx的服務器

+0

我將源代碼的權限更改爲777遞歸,所有者爲ftpuser1。我重新啓動了nginx,但仍然存在問題。 – 2014-09-08 07:47:26

0
  1. 修復右括號「}」在配置結束後(不是問題)
  2. 嘗試把「用戶ftpuser1;」在「server {..}」之前的配置頂部
+0

1.它已經關閉了,而粘貼其他編輯它來到一行以上時,錯誤地顯示註釋,它沒有評論,它正確關閉。 2.在nginx.conf用戶ftpuse1已經有 – 2014-09-07 05:32:12

+0

那麼用戶本身在創建時沒有權限? – 2014-09-11 15:14:17

相關問題