我对服务器操作还很陌生。我正尝试使用 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)
我可能遗漏了一些显而易见的东西或者没有完全理解,但非常感谢任何帮助!
答案1
我从来没有打开过 80 端口……新手错误。我希望有同样问题的人会偶然发现这一点,并意识到他们需要打开端口 80