Nginx+uWsgi+Django
系統環境:Ubuntu 14.04LTS
Nginx
官網:http://nginx.org/
安裝
1. 系統安裝
<code><span>$sudo</span> apt<span>-get</span> install nginx</code>
2.安裝來源 原始碼裝置套件 網址:http://nginx.org/en/download.html
安裝依賴函式庫
解壓,配置,編譯,安裝
<code><span>$tar</span> zxvf nginx<span>-</span><span>1.8</span><span>.0</span><span>.</span>tar<span>.</span>gz <span>$cd</span> nginx<span>-</span><span>1.8</span><span>.0</span> $<span>.</span>/configure <span>--</span><span>with</span><span>-pcre</span><span>--</span><span>with</span><span>-http_ssl_module</span><span>--</span><span>with</span><span>-http_realip_module</span><span>--</span><span>with</span><span>-http_gzip_static_module</span><span>--</span><span>with</span><span>-http_secure_link_module</span><span>--</span><span>with</span><span>-http_stub_status_module</span><span>--</span><span>with</span><span>-debug</span><span>$make</span><span>$sudo</span> make install</code>
<code>whereis nginx</code>
在啟動時nignx是遇到命令無法識別,發現是nginx模組未安裝全
<code><span>$sudo</span> apt<span>-get</span> install nginx<span>-core</span></code>
然後啟動nginx
<code><span>sudo</span> nginx</code>
nginx預設的設定介面即表示啟動成功
Welcome to nginx
3. nginx設定檔夾
<code><span>$sudo</span> nginx <span>#$sudo nginx -s start</span></code>
<code><span>$sudo</span> nginx <span>-s</span> stop</code>
<code><span>$sudo</span> nginx <span>-s</span> reload</code>
解壓縮,配置,編譯,安裝
<code><span>$sudo</span> apt<span>-get</span> install uwsgi<span>-plugin</span><span>-python</span><span>$sudo</span> apt<span>-get</span> install uwsgi</code>
當安裝完成後,會提示end of uWSGI configration
測試uWSGI
<code><span>$tar</span> zxvf uwsgi-<span>2.0</span><span>.6</span>.tar.gz <span>$cd</span> uwsgi-<span>2.0</span><span>.6</span><span>$sudo</span><span>python</span> setup.py install</code>
rrreGI
<code><span>$uwsgi</span> --version</code>
在瀏覽器輸入位址存取
<code><span><span>def</span><span>application</span><span>(env, start_response)</span>:</span> start_response(<span>'200 OK'</span>, [(<span>'Content-Type'</span>,<span>'text/html'</span>)]) <span>return</span> [<span>b"Hello World"</span>]</code>
瀏覽器輸出Hello World,表示安裝成功
相關指令
啟動:
執行對應腳本關閉:
<code><span>$uwsgi</span><span>-</span><span>-</span><span>http</span><span>:9090</span><span>-</span><span>-</span><span>wsgi</span><span>-</span><span>file</span><span>test</span><span>.</span><span>py</span></code>
Django
安裝依賴庫
<code>http:<span>//localhost:9090/</span></code>
下載原始碼:https://www.djangoproject.com/download/
解壓縮,配置,編譯,安裝<code><span>$killall</span><span>-</span><span>9</span> uwsgi <span>$killall</span><span>-s</span> HUP /<span>var</span>/www/uwsgi <span>$killall</span><span>-s</span> HUP /usr/<span>local</span>/bin/uwsgi </code>
<code><span>$sudo</span> apt<span>-get</span> install python2<span>.7</span></code>
參考
http://uwsgi-docs. latest/WSGIquickstart.html
http://segmentfault.com/q/1010000002523354http://www.nowamagic.net/academy/detail/1330331
http://www.nowamagic.net/academy/detail/1330334http://www.linuxidc.com/Linux/2014-09/106928.htm
版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。