您好,登錄后才能下訂單哦!
這篇文章主要介紹django啟動uwsgi報錯怎么辦,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
uwsgi介紹
uWSGI是一個Web服務器,它實現了WSGI協議、uwsgi、http等協議。Nginx中HttpUwsgiModule的作用是與uWSGI服務器進行交換。
要注意 WSGI / uwsgi / uWSGI 這三個概念的區分。
WSGI是一種Web服務器網關接口。它是一個Web服務器(如nginx,uWSGI等服務器)與web應用(如用Flask框架寫的程序)通信的一種規范。
uwsgi是一種線路協議而不是通信協議,在此常用于在uWSGI服務器與其他網絡服務器的數據通信。
而uWSGI是實現了uwsgi和WSGI兩種協議的Web服務器。
uwsgi協議是一個uWSGI服務器自有的協議,它用于定義傳輸信息的類型(type of information),每一個uwsgi packet前4byte為傳輸信息類型描述,它與WSGI相比是兩樣東西。
uwsgi性能非常高
最近在django啟動uwsgi報錯的時候,發現了一些錯誤,下面來一起看看吧
查看uwsgi.log
*** Starting uWSGI 2.0.17 (64bit) on [Thu Apr 5 17:46:15 2018] *** compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-18) on 05 April 2018 02:08:03 os: Linux-2.6.32-642.6.2.el6.x86_64 #1 SMP Wed Oct 26 06:52:09 UTC 2016 nodename: GDJ_DEV machine: x86_64 clock source: unix detected number of CPU cores: 1 current working directory: /xxx/xxx/xxx/xxx writing pidfile to uwsgi.pid detected binary path: /xxx/xxx/.virtualenvs/h2/bin/uwsgi !!! no internal routing support, rebuild with pcre support !!! chdir() to /xxx/xxx/xxx/xxx your processes number limit is 100000 your memory page size is 4096 bytes detected max file descriptor number: 100000 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uWSGI http bound on 172.21.0.5:8000 fd 4 uwsgi socket 0 bound to TCP address 127.0.0.1:33522 (port auto-assigned) fd 3 Python version: 3.6.4 (default, Mar 24 2018, 10:32:21) [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] Python main interpreter initialized at 0x1ff10d0 python threads support enabled your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 416880 bytes (407 KB) for 8 cores *** Operational MODE: preforking+threaded *** failed to open python file xxx/uwsgi.ini unable to load app 0 (mountpoint='') (callable not found or import error) *** no app loaded. going in full dynamic mode *** *** uWSGI is running in multiple interpreter mode *** spawned uWSGI master process (pid: 4865) spawned uWSGI worker 1 (pid: 4866, cores: 2) spawned uWSGI worker 2 (pid: 4867, cores: 2) spawned uWSGI worker 3 (pid: 4868, cores: 2) spawned uWSGI worker 4 (pid: 4869, cores: 2) spawned uWSGI http 1 (pid: 4870) --- no python application found, check your startup logs for errors --- [pid: 4869|app: -1|req: -1/1] 118.26.10.242 () {40 vars in 777 bytes} [Thu Apr 5 17:46:31 2018] GET /user/login/ => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
解決第一個報錯,注意操作的先后順序:
1.卸載uwsgi
pip uninstall uwsgi
#注意此時卸載,pip會有緩存留在系統里
2.安裝pcre支持庫
yum install pcre pcre-devel pcre-static
3.繼續安裝uwsgi,不走pip緩存
pip install uwsgi -I --no-cache-dir
#啟動uwsgi,已經沒有“ !!! no internal routing support, rebuild with pcre support !!! ”報錯了
解決第二個報錯:
需要在你的uwsgi.ini文件中module指定項目下面的wsgi:
module=xxx.wsgi
#注:xxx為項目名稱,startproject那個項目名稱,這個錯誤解決后,下面的訪問錯誤自然而然的就解決了!
附:我的uwsgi.ini配置文件
[uwsgi] #socket=ip:port #使用nginx代理請求時配置,直接訪問uwsgi使用http方式 http=ip:port chdir=/xxx/xxx #項目根目錄的絕對路徑 wsgi-file=xxx/uwsgi.ini #項目目錄下的uwsgi.ini module=xxx.wsgi #指向項目下的wsgi模塊 processes=4 threads=2 master=True py-atuo-reload=1 env=DJANGO_SETTINGS_MODULE=xxx.settings pidfile=uwsgi.pid daemonize=uwsgi.log
以上是“django啟動uwsgi報錯怎么辦”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。