大多數可用教程顯示如何使用上游HTTP服務器(如NGINX)設置uWSGI。但是uWSGI單獨可以作爲路由器/代理/負載平衡器的精美行爲 - 請參閱this 對於我的項目,此刻我不想設置NGINX,所以我開始探索通過uWSGI提供網頁的選項。這裏的答案顯示瞭如何使用Pyramid進行設置。將uWSGI設置爲帶有金字塔的網絡服務器(無NGINX)
5
A
回答
10
我正在使用pyramid_mongodb腳手架,我已修改它以使其在python3上工作。有關詳細信息,請參閱here。 假設我們有一個金字塔項目(使用pcreate -s pyramid_mongodb MyProject
創建)。 以下是開發/ production.ini
[uwsgi]
http = 0.0.0.0:8080
#http-to /tmp/uwsgi.sock - use this for standalone mode
#socket = :9050
master = true
processes = 2
harakiri = 60
harakiri-verbose = true
limit-post = 65536
post-buffering = 8192
daemonize = ./uwsgi.log
pidfile = ./orange_uwsgi.pid
listen = 128
max-requests = 1000
reload-on-as = 128
reload-on-rss = 96
no-orphans = true
#logto= <log file>
log-slow = true
virtualenv = <path to virtual environment>
#file = /path/to/pyramid.wsgi
#callable = application
need-app = true
也需要uWSGI配置,因爲我們使用uWSGI我們可以註釋掉從INI
#[server:main]
#use = egg:waitress#main
#host = 0.0.0.0
#port = 6544
server
部分運行服務器使用 uwsgi --ini-paste development.ini
2
更容易!不需要修改所有「development.ini」文件。 在應用中創建文件夾,您的「發展」和「生產」的ini文件所在,一個名爲「wsgi.app」有以下內容的文件:
from pyramid.paster import get_app,setup_logging
ini_path = '/pathto/myapp/development.ini'
setup_logging(ini_path)
application = get_app(ini_path,'main')
創建讓我們說「myapp.conf」與它的內容:
[uwsgi]
socket = 127.0.0.1:3053
uid = daemon
gid = daemon
venv = /pathto/myenv
project_dir = /pathto/myapp
chdir = %(project_dir)
master = true
plugins = plugins/python/python
check-static = %(project_dir)
static-skip-ext = .py
static-skip-ext = .pyc
static-skip-ext = .inc
static-skip-ext = .tpl
pidfile2 = /var/run/uwsgi/myinfo.pid
disable-logging = true
processes = 8
cheaper = 2
enable-threads = true
offload-threads = N
py-autoreload = 1
wsgi-file = /pathto/myapp/wsgi.py
和NGINX configuation很簡單:用
server {
listen [xxxx:xxxx:xxxx:xxx:xxxx:xxxx]:80; #for IPv6
listen xxx.xxx.xxx.xxx:80; #for IPv4
server_name myapp.domain.com;
location/{
try_files $uri @uwsgi;
}
location @uwsgi {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3053;
}
}
- 重啓nginx的「/路徑/到/ usr/sbin目錄/ nginx的-s刷新」
- 啓動uwsgi過程 - >更改爲 「CD /usr/local/uwsgi-2.0.9」 - > ./uwsgi -ini /var/www/myapp.conf
相關問題
- 1. 如何配置金字塔+ uWSGI + SQLAlchemy的
- 2. 金字塔pserve服務器爲https
- 3. 在Nginx上使用uWSGI部署金字塔的問題
- 4. (nginx + uwsgi + django)。 nginx的服務器不允許請求打uwsgi服務器
- 5. 幫助設置django的nginx + fastcgi網絡服務器
- 6. 我無法設置金字塔和deform_bootstrap?
- 7. 如何確保與uWSGI和金字塔
- 8. 金字塔燒杯和uwsgi入門
- 9. 多線程requests.post使用uWSGI,金字塔
- 10. 金字塔開源網絡應用
- 11. 爲已有的url設置不同的網絡服務器
- 12. 將uWSGI HTTP服務器轉換爲Nginx的後臺
- 13. 通過Nginx的uwsgi + django - uwsgi設置/ spawn?
- 14. 如何在使用同一個網絡服務器的PHP網站前放置金字塔?
- 15. 如何在金字塔內設置消息/通知服務?
- 16. Django後面uwsgi + nginx無法設置cookie
- 17. 用nginx和uWSGI服務django
- 18. Django + Nginx + uWSGI:內部服務器錯誤
- 19. Rails框架&Nginx網絡服務器
- 20. 在Monodroid上設置網絡服務器
- 21. PHP服務器網絡用戶設置
- 22. 如何設置Apache網絡服務器
- 23. 設置tomcat個人網絡服務器
- 24. 帶代理服務器的nginx位置
- 25. nginx和uwsgi服務器中uwsgi模塊的區別
- 26. 金字塔uWSGI部署,而不是可迭代的 '路由器'
- 27. 用uwsgi和nginx設置django
- 28. 無服務器的網絡套接字服務器?
- 29. 金字塔服務器沒有提供Flash文件
- 30. Python金字塔PServe拒絕服務
本例中的NGINX部分僅爲(可選)。但在這一點上,應用程序應該能夠在http://127.0.0.1:3053上收聽請求 – SmileMZ 2015-05-14 10:24:18