首頁 > 後端開發 > php教程 > Nginx+uWsgi+Django

Nginx+uWsgi+Django

WBOY
發布: 2016-07-30 13:30:46
原創
960 人瀏覽過

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>
登入後複製
預設安裝路徑為:/usr/local/nginx

在啟動時nignx是遇到命令無法識別,發現是nginx模組未安裝全

<code><span>$sudo</span> apt<span>-get</span> install nginx<span>-core</span></code>
登入後複製

然後啟動nginx

<code><span>sudo</span> nginx</code>
登入後複製
透過瀏覽器訪問http://localhost:80

nginx預設的設定介面即表示啟動成功

Welcome to nginx


3. nginx設定檔夾

conf : /usr/local/nginx/conf

<code><span>$sudo</span> nginx 
<span>#$sudo nginx -s start</span></code>
登入後複製
uWSGI

安裝教學:http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html

1. 安裝

<code><span>$sudo</span> nginx <span>-s</span> stop</code>
登入後複製
bit源碼安裝

1. 安裝

<code><span>$sudo</span> nginx <span>-s</span> reload</code>
登入後複製
bit源代碼安裝

1. .it/uwsgi/wiki/WikiStart

解壓縮,配置,編譯,安裝

<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>
登入後複製
編寫測試腳本,test.pyGI

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>
登入後複製

安裝Django

下載原始碼: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>
登入後複製
測試Django

列印Django版本資訊

<code><span>$sudo</span> apt<span>-get</span> install python2<span>.7</span></code>
登入後複製

當出現如上顯示時,說明Django安裝成功

參考

http://uwsgi-docs. latest/WSGIquickstart.html

http://segmentfault.com/q/1010000002523354

http://www.nowamagic.net/academy/detail/1330331

http://www.nowamagic.net/academy/detail/1330334

http://www.linuxidc.com/Linux/2014-09/106928.htm



版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。

以上就介紹了Nginx+uWsgi+Django,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板