1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#安装uwsgi
pip install uwsgi
#编辑测试文件,用于测试uwsgi是否能正常使用
vi test.py
def
application(env,start_response):
start_response(
'200 OK'
,[(
'Content-Type'
,
'text/html'
)])
return
[
"hello world"
]
#窗口启动uwsgi测试:
uwsgi
-
-
http :
9090
-
-
wsgi
-
file
test.py
#在浏览器中打开http://127.0.0.1:9090
弹出hello world为正常。
#编辑uwsgi配置文件:
vi
/
etc
/
uwsgi.ini
[uwsgi]
#vhost = false
#plugins = python
socket
=
192.168
.
1.121
:
9090
master
=
true
enable
-
threads
=
true
workers
=
1
wsgi
-
file
=
project1
/
wsgi.py
chdir
=
/
home
/
darren
/
django
/
project1
/
daemonize
=
/
var
/
log
/
uwsgi9090.log
#或者
[uwsgi]
socket
=
192.168
.
1.121
:
9090
master
=
true
vhost
=
true
#多站模式
workers
=
2
reload
-
mercy
=
10
vacuum
=
true
#退出重启会清理文件
max
-
requests
=
1000
limit
-
as
=
512
buffer
-
size
=
30000
chmod
-
socket
=
666
wsgi
-
file
=
project1
/
wsgi.py
chdir
=
/
home
/
darren
/
django
/
project1
/
pidfile
=
/
var
/
run
/
uwsgi.pid
#daemonize = /var/log/uwsgi.log
#启动uwsgi
uwsgi
-
-
ini
/
etc
/
uwsgi.ini
#nginx配置
server {
listen
80
;
server_name localhost;
access_log logs
/
host.access.log main;
location
/
{
#root /home/darren/django/project1;
index index.html index.htm;
include uwsgi_params;
uwsgi_pass
192.168
.
1.121
:
9090
;
}
|
版权声明:原创作品,谢绝转载。否则将追究法律责任
本文转自 王家东哥 51CTO博客,原文链接:http://blog.51cto.com/xiaodongge/1931043