我創建了一個不使用虛擬環境的django應用程序。我已經安裝了nginx並嘗試通過uwsgi應用程序將它們集成在一起。 這裏是我的配置文件。django nginx uwsgi不工作
[uwsgi]
chdir = /home/elastic/workspace/ES_Brevetti
wsgi-file = ES_Brevetti/wsgi.py
master = true
processes = 5
uid = nginx
gid = nginx
socket = unix:///socket/uwsgi.sock
chmod-socket = 666
vacuum = true
我已經創建與許可文件/sockect/uwsgi.sock 777
CHOWN nginx的:nginx的-R /sockect/uwsgi.sock
和下面的nginx CONF文件:
upstream django {
server unix:///socket/uwsgi.sock; # for a file socket
#server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
server {
listen 80;
server_name 10.184.2.231;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
charset utf-8;
location /static/ {
alias /home/elastic/workspace/ES_Brevetti;
}
location/{
include uwsgi_params;
uwsgi_pass unix:///socket/uwsgi.sock;
}
}
當我啓動 「啓動systemctl nginx的」 nginx的開始,錯誤: connect()以UNIX:///socket/uwsgi.sock失敗(111:連接被拒絕),同時連接到上游,
當我運行uwsgi --ini /etc/uwsgi/sites/ES_Brevetti.ini它並不與錯誤運行:
.....
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
bind(): Permission denied [core/socket.c line 230]
什麼,我做錯了什麼?在谷歌,我只能看到與VENV配置,而我不使用虛擬環境。
現在uwsgi啓動並運行,但不斷收到以下錯誤:502錯誤的網關和nginx日誌文件我得到「connect()unix:///socket/uwsgi.sock失敗(111:連接被拒絕)while連接到上游「。請幫忙嗎? – user3779542
你說運行uwsgi不會運行一個錯誤,但輸出顯示錯誤'bind():Permission denied',這看起來與你的'111:Connection refused'錯誤相同。這表明你的套接字沒有正確的所有權/許可權。你可以顯示套接字的權限並說出你正在運行的是什麼用戶? – daphtdazz
好的,謝謝你的回覆。我對uwsgi.sock的套接字權限是777,所有者是nginx:nginx nginx服務器以root身份啓動:「sudo systemctl start nginx」否則它不會啓動,而uwsgi以用戶「elastic」的身份運行,即我是用戶登錄但ini文件我有uid = nginx gid = nginx ....任何幫助?順便說一句我已經添加nginx – user3779542