Ubuntu

Ubuntu 12.04 伺服器 - 帶有 uWsgi 的 Django 無法正常工作

  • February 27, 2014

我對使用伺服器還很陌生。我正在嘗試使用 uwsgi 和 nginx 在 Ubuntu 12.04 AWS 上執行 Django。

我找到了我正在關注的教程:http: //uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

我創建了一個虛擬 evn:

virtualenv uwsgi-tutorial
cd uwsgi-tutorial
source bin/activate

然後我使用 pip 安裝了 Python 和 Django。然後我開始了一個名為mysite

然後我安裝了uwsgi

pip install uwsgi

然後我創建了一個 test.py 文件:

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

然後我執行 uwsgi:

uwsgi --http :8000 --wsgi-file test.py

該教程聲稱,如果我將瀏覽器指向我http://myip:8000應該Hello World在瀏覽器中看到的內容。但是,我的瀏覽器一直在等待,就好像它根本沒有連接到伺服器一樣。

當我執行時,uwsgi --http :8000 --wsgi-file test.py我在終端中得到這個輸出:

*** Starting uWSGI 2.0.1 (64bit) on [Tue Feb 25 15:26:43 2014] ***
compiled with version: 4.6.3 on 25 February 2014 05:36:40
os: Linux-3.2.0-59-virtual #90-Ubuntu SMP Tue Jan 7 23:02:33 UTC 2014
nodename: ip-172-31-13-105
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/spencer/uwsgi-tutorial/mysite
detected binary path: /home/spencer/uwsgi-tutorial/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 4592
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8000 fd 4
spawned uWSGI http 1 (pid: 9729)
uwsgi socket 0 bound to TCP address 127.0.0.1:37347 (port auto-assigned) fd 3
Python version: 2.7.3 (default, Sep 26 2013, 20:13:52)  [GCC 4.6.3]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1bbc670
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72760 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x1bbc670 pid: 9728 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 9728, cores: 1)

我可能遺漏了一些明顯或不完全理解的東西,但非常感謝任何幫助!

我從來沒有打開80埠…菜鳥錯誤。我希望有同樣問題的人會偶然發現這一點並意識到他們需要打開 80 埠

引用自:https://serverfault.com/questions/578174