2014年6月11日 星期三

安裝uWSGI配合Nginx Server

【安裝uwsgi】

參考:http://www.openfoundry.org/tw/tech-column/8536-introduction-of-python-extension-management-tools

先安裝 pip 套件管理程式
easy_install pip

參考:https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/uwsgi/
安裝gcc
yum install gcc

安裝
yum install python-devel

安裝目前stable版的uwsgi
pip install uwsgi

參考文章:http://django-china.cn/topic/101/

測試安裝結果

測試一:直接執行uwsgi命令,不加任何參數
uwsgi

測試二:
新增測試檔案
cd /home/john/www/test.py

# test.py
def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return "Hello World"

執行uwsgi伺服器
uwsgi --http :8001 --wsgi-file test.py

用瀏覽器開啟網頁
http://127.0.0.1:8001

成功的話,應該會出現
Hello World