django + uwsgi + nginx 配置問題匯總

1、DisallowedHost at /admin Invalid HTTP_HOST header: '119.45.124.33:8011'. You may need to add '119.45.124.33' to ALLOWED_HOSTS.

解決方法:
修改項目中的 setting.py 文件

ALLOWED_HOSTS = ['*']  #在這里請求的host添加了*

2、E45: 'readonly' option is set (add ! to override)

解決方案, :wq!強制關閉文件后,在命令行里輸入:sudo !!后回車。

3、** Operational MODE: preforking+threaded *** failed to open python file wsgi.py unable to load app 0 (mountpoint='') (callable not found or import error) *** no app loaded. going in full dynamic mode ***

上述報錯是由于uwsgi.ini 配置文件中的項目路徑配置錯誤導致
chdir 是項目的絕對路徑
wsgi-file 是wsgi.py相對于chdir路徑的相對路徑
例如:新建Django項目Test,絕對路徑是 /home/user_001/Test,wsgi.py的路徑是 /home/user_001/Test/Test/wsgi.py 。
那么配置如下:

chdir = /home/user_001/Test
# 注意Test前不要加 /
wsgi-file = Test/wsgi.py 

4、Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

一般是etc/nginx/nginx.conf 配置不符合規(guī)則,使用 sudo nginx -t檢查

5、# nginx: [emerg] “server” directive is not allowed here

etc/nginx/nginx.conf 的配置中,server需要放在http里面

events {
    ...
}
http {
    ...
    server {
        ...
    }
}
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容