参考链接 :https://www.cnblogs.com/wswang/p/5521566.html
环境:
OS:Mac10.12.6
Server:uWSGI 2.0.18
1.1 创建一个test.py文件:
# test.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World"] # python3
#return ["Hello World"] # python2
1.2 启动uWSGI服务器:
uwsgi --http :8000 --wsgi-file test.py
意思是使用8000端口启动这个文件,效果如下:
(py3_test_venv) shejishi03deiMac:Test shejishi03$ uwsgi --http :8000 --wsgi-file test.py
*** Starting uWSGI 2.0.18 (64bit) on [Wed Jan 1 12:38:48 2020] ***
compiled with version: 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2) on 14 November 2019 08:11:24
os: Darwin-16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64
nodename: shejishi03deiMac.local
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /Users/shejishi03/PycharmProjects/Test/Test
detected binary path: /Users/shejishi03/.virtualenvs/py3_test_venv/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 709
your memory page size is 4096 bytes
detected max file descriptor number: 10240
lock engine: OSX spinlocks
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8000 fd 4
spawned uWSGI http 1 (pid: 3749)
uwsgi socket 0 bound to TCP address 127.0.0.1:58089 (port auto-assigned) fd 3
Python version: 3.7.5 (default, Nov 11 2019, 11:14:37) [Clang 9.0.0 (clang-900.0.39.2)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x7f9b75c0a180
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72888 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x7f9b75c0a180 pid: 3748 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 3748, cores: 1)
2.3 访问本机IP及端口 127.0.0.1:8000,
浏览器会显示 hello world

这就说明uWSGI启动成功~可以设置uWSGI启动django了
在Mac OS 10.12.6上,安装uWSGI 2.0.18并创建test.py文件进行测试。通过启动uWSGI服务器监听8000端口,然后在浏览器中访问127.0.0.1:8000,成功显示'hello world',标志着uWSGI已成功配置。
990

被折叠的 条评论
为什么被折叠?



