uwsgi 无法在云服务器上工作
uwsgi cannot work on a cloud server
我在云服务器上安装了uwsgi,测试我写了一个python脚本来测试它,如下:
# test.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World"] # python3
然后我运行如下:
uwsgi --http :8001 --wsgi-file test.py
我得到了一些这样的信息:
pcre jit disabled
detected number of CPU cores: 1
current working directory: /root
detected binary path: /root/.pyenv/versions/2.7.6/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7840
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 :8001 fd 4
spawned uWSGI http 1 (pid: 8524)
uwsgi socket 0 bound to TCP address 127.0.0.1:53307 (port auto-assigned) fd 3
Python version: 2.7.6 (default, May 6 2015, 18:35:37) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1108510
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72768 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x1108510 pid: 8491 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 8491, cores: 1)
但是当我在浏览器上输入IP地址和端口时,它无法回显"Hello World"。
检查防火墙规则。开箱即用的外部访问往往会禁用 8001 等任意端口。应该可以从服务器上的命令行正常工作,例如$ curl localhost:8001
.
我在云服务器上安装了uwsgi,测试我写了一个python脚本来测试它,如下:
# test.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World"] # python3
然后我运行如下:
uwsgi --http :8001 --wsgi-file test.py
我得到了一些这样的信息:
pcre jit disabled
detected number of CPU cores: 1
current working directory: /root
detected binary path: /root/.pyenv/versions/2.7.6/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7840
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 :8001 fd 4
spawned uWSGI http 1 (pid: 8524)
uwsgi socket 0 bound to TCP address 127.0.0.1:53307 (port auto-assigned) fd 3
Python version: 2.7.6 (default, May 6 2015, 18:35:37) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1108510
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72768 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x1108510 pid: 8491 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 8491, cores: 1)
但是当我在浏览器上输入IP地址和端口时,它无法回显"Hello World"。
检查防火墙规则。开箱即用的外部访问往往会禁用 8001 等任意端口。应该可以从服务器上的命令行正常工作,例如$ curl localhost:8001
.