我知道這個問題已經被問過一百萬次了,而且我幾乎嘗試了所有的“解決方案”都無濟于事。我在想我的問題可能是獨一無二的。
uwsgi.ini:
module = wsgi:app
master = true
processes = 5
socket = elekto.sock
chmod-socket = 666
vacuum = true
die-on-term = true
logto = /home/richardgrecoson/elekto/elekto.log
/etc/nginx/sites-enabled/elekto :
server {
listen 80;
server_name my_ip;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/richardgrecoson/elekto/elekto.sock;
}
}
/etc/systemd/system/elekto.service
[Unit]
Description=uWSGI instance to serve myproject
After=network.target
[Service]
User=richardgrecoson
Group=www-data
WorkingDirectory=/home/richardgrecoson/elekto
Environment="PATH=/home/richardgrecoson/elekto/.venv/bin"
ExecStart=/home/richardgrecoson/elekto/.venv/bin/uwsgi --ini uwsgi.ini
[Install]
WantedBy=multi-user.target
uj5u.com熱心網友回復:
您的 NGINX 不允許對套接字檔案進行 r/w/x。讓我們嘗試一些事情。
將套接字的權限更改為0777并檢查它ls /home/richardgrecoson/elekto/elekto.sock
一般來說,允許 NGINX 的運行用戶 r/w/x 套接字是很重要的。nginx 的運行用戶是 "normally" nginx。通過鍵入來檢查ps -elf |grep nginx
如果是 NGINX,我會將套接字的權限更改回660并將用戶和組更改為nginx.
有了這個,nginx 用戶將可以訪問套接字。
如果您想為套接字使用與 nginx 不同的運行用戶,請創建一個新用戶并將其添加到 nginx 組
usermod -a -G nginx yourusername。這也適用660。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/428591.html
下一篇:如何使用nginx將所有以www.example.com/page開頭的鏈接重寫為www.example.com/new-page
