Python项目部署到服务器
将python项目上传到服务器
安装虚拟环境
1
pip install virtualenv
在合适的目录下创建虚拟环境
1
virtualenv ENV
切换到虚拟环境并启用
1
2cd ENV
source ./bin/activate运行项目
1
nohup python <main文件> &
查看项目运行状态
1
netstat -lnp | grep <端口号>
停止项目
1
kill <PID>
Ex
- 配置域名绑定IP+端口,设置nginx反向代理
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#PROXY-START/
location ~* \.(php|jsp|cgi|asp|aspx)$
{
proxy_pass http://zzuli.love:1314;
proxy_set_header Host zzuli.love;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
}
location /
{
proxy_pass http://zzuli.love:1314;
proxy_set_header Host zzuli.love;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
add_header Cache-Control no-cache;
expires 12h;
}
#PROXY-END/
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.