大多數可用教程顯示如何使用上游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 + django)。 nginx的服務器不允許請求打uwsgi服務器
- 4. 幫助設置django的nginx + fastcgi網絡服務器
- 5. 多線程requests.post使用uWSGI,金字塔
- 6. 如何確保與uWSGI和金字塔
- 7. 將uWSGI HTTP服務器轉換爲Nginx的後臺
- 8. 通過Nginx的uwsgi + django - uwsgi設置/ spawn?
- 9. 如何在使用同一個網絡服務器的PHP網站前放置金字塔?
- 10. 如何在金字塔內設置消息/通知服務?
- 11. Django後面uwsgi + nginx無法設置cookie
- 12. Django + Nginx + uWSGI:內部服務器錯誤
- 13. Rails框架&Nginx網絡服務器
- 14. 如何設置Apache網絡服務器
- 15. 設置tomcat個人網絡服務器
- 16. PHP服務器網絡用戶設置
- 17. 金字塔服務器沒有提供Flash文件
- 18. Nginx的網絡服務器無法不啓動本地主機
- 19. Python金字塔PServe拒絕服務
- 20. 金字塔gunicorn和女服務員
- 21. 具有一個IP的多個網站:使用代理服務器和代理緩存(flask,uwsgi,nginx)的設置
- 22. 在windows上設置mod_wsgi和金字塔
- 23. 如何使用帶有Nginx的uWSGI FastRouter?
- 24. 爲網絡設置閃亮的服務器
- 25. 當我設置nginx + django服務時,uwsgi無法加載應用程序
- 26. 無法通過網絡服務器使用網絡服務
- 27. ImportError:沒有名爲mysite.wsgi的模塊 - uwsgi和nginx設置
- 28. vmware上的金字塔服務器響應非常緩慢
- 29. 設置量角器的網絡驅動器/硒服務器
- 30. 最容易爲Windows設置本地網絡服務器
本例中的NGINX部分僅爲(可選)。但在這一點上,應用程序應該能夠在http://127.0.0.1:3053上收聽請求 – SmileMZ 2015-05-14 10:24:18