在linux上部署好crm
在linux上部署好crm
1.准备python3 的虚拟环境(virtualenv wrapper)
workon 虚拟环境名字 #自动找到,然后激活
mkvirtualenv s23venv #创建s23venv
workon s23_crm #激活
2.用uwsgi,指定配置文件启动crm
uwsgi把crm的代码运行在了8000端口上
uwsgi --ini uwsgi.ini
3.配置nginx,去访问crm的代码
我们自定义的,crm的入口是nginx的80端口
server {
#nginx监听的地址
listen 80;
#定义网站的域名
server_name _;
#charset koi8-r;
#nginx的url匹配 , /这个斜杠就代表这样的请求: 192.168.13.117:85/
#这个是最低级匹配,所有的请求都会进入location,进行处理
location / {
#基于uwsgi协议的请求转发,给后端django的启动地址
uwsgi_pass 0.0.0.0:8000;
include uwsgi_params;
}
#在django中收集所有的静态文件,放在/opt/crms23/crmstatic 然后丢给nginx去寻找
location /static {
alias /opt/crms23/crmstatic;
}
}
# 搭建 https https://pythonav.com/wiki/detail/3/40/
server{
listen 443;
多了一些添加证书的配置
}
4.启动mariadb(mysql)
我们是通过yum安装的mariadb,因此直接
systemctl start mariadb
5.通过supervisor管理crm
安装supervisor工具
(1).一是通过 yum安装
yum install supervisor -y
(2)生成supervisor的配置文件
echo_supervisord_conf > /etc/supervisord.conf
(3).修改supervisor配置文件,添加管理crm的任务
vim /etc/supervisord.conf
添加如下配置
[program:s23_crm]
command=/root/Envs/s23_crm/bin/uwsgi --ini /opt/crms23/se_crm/uwsgi.ini ; 启动s23crm的完整绝对路径命令
autorestart=true ; 程序退出后自动重启,可选值:[unexpected,true,false],默认为unexpected,表示进程意外杀死后才重启
stopasgroup=true ;默认为false,进程被杀死时,是否向这个进程组发送stop信号,包括子进程
killasgroup=true ;默认为false,向进程组发送kill信号,包括子进程
(4).启动supervisor服务,且管理进程
[root@s23_linux conf]# supervisord -c /etc/supervisord.conf # -c指定配置文件 ,管理服务端的命令 supervisord
[root@s23_linux conf]#
[root@s23_linux conf]#
[root@s23_linux conf]#
[root@s23_linux conf]#
[root@s23_linux conf]# supervisorctl #管理任务,管理进程的命令
s23_crm RUNNING pid 2520, uptime 0:00:04
supervisor>
supervisor>
supervisor>
(5)。管理supervisor的命令
二、更新新的配置到supervisord
supervisorctl update
三、重新启动配置中的所有程序
supervisorctl reload
四、启动某个进程(program_name=你配置中写的程序名称)
supervisorctl start program_name
五、查看正在守候的进程
supervisorctl
六、停止某一进程 (program_name=你配置中写的程序名称)
spervisorctl stop program_name
七、重启某一进程 (program_name=你配置中写的程序名称)
supervisorctl restart program_name
八、停止全部进程
supervisorctl stop all
九、启动所有进程
supervisorctl start all
注意:显示用stop停止掉的进程,用reload或者update都不会自动重启。
启动路飞学城
启动路飞学城
1.准备好虚拟环境
[root@s23_linux ~]# workon luffys23
2.启动drf后台,用supervisor去启动uwsgi
(1)编辑vim /etc/supervisord.conf 添加管理路飞的命令
[program:s23_luffy]
command=/root/Envs/luffys23/bin/uwsgi --ini /opt/luffys23/luffy_boy/uwsgi.ini ; 启动s23crm的完整绝对路径命令
autorestart=true ; 程序退出后自动重启,可选值:[unexpected,true,false],默认为unexpected,表示进程意外杀死后才重启
stopasgroup=true ;默认为false,进程被杀死时,是否向这个进程组发送stop信号,包括子进程
killasgroup=true ;默认为false,向进程组发送kill信号,包括子进程
(2)添加到/etc/supervisord.conf 最下面即可
3.重启supervisord让它生效
杀死supervisord进程的pid,然后重新启动 ,保证没有uwsgi在启动
supervisord -c /etc/supervisord.conf
4.检查crm和路飞的后台是否正常,
(luffys23) [root@s23_linux luffy_boy]# supervisorctl
s23_crm RUNNING pid 4706, uptime 0:00:02
s23_luffy RUNNING pid 4705, uptime 0:00:02
supervisor>
5.配置nginx前端
server {
listen 81;
server_name _;
#当我访问 192.168.13.117:81的时候,就进入如下的配置
location / {
#定义网页根目录
root /opt/luffys23/07-luffy_project_01/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
}
server {
listen 8001;
server_name _;
location / {
include uwsgi_params;
uwsgi_pass 0.0.0.0:8002;
}
}
6.购物车功能是写入到redis数据库的,启动redis
yum install redis -y
systemctl start redis