码迷,mamicode.com
首页 > 其他好文 > 详细

部署django+uwsgi+Virtualenv+nginx+supervisor详细步骤

时间:2020-05-19 23:07:29      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:comment   soc   ted   tar   out   依赖   com   zip   编译   

1.安装依赖包

yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++ 

# yum方法安装的,可以用 yum list installed 查找,如果是查找指定包,用 yum list installed | grep "软件名或者包名" 

2.安装python3

1、下载python安装包

wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz

2、 使用root权限打开终端,进行解压缩操作

tar -zxvf Python-3.6.5.tgz

3、将目录重命名

mv Python-3.6.5 python3.6

4、修改setup文件,启动ssl模块

vi /root/python3.6/Modules/Setup.dist
#使用/Socket 找到所在行

#修改结果如下:
# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl
_ssl _ssl.c -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl -L$(SSL)/lib -lssl -lcrypto

5、进入python3.6目录编译安装

./configure --with-ssl --prefix=/opt/python3.6  # 目录/opt/python3.6可以根据自己的喜好随意选择,此目录为python的真正安装目录

6、make&make install

make & make install

7、创建软连接

ln -s /opt/python3.6/bin/python3.6 /usr/bin/python3
ln -s /opt/python3.6/bin/pip3 /usr/bin/pip3

3.安装 virtualenv

#更改国内源
pip3 install pip -U
pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/

1、安装 virtualenv 模块

pip3 install virtualenv==16.7.9 #使用此版本,最新版有bug

2、查看版本

virtualenv --version

3、查看路径

find / -name virtualenv

4、创建软连接

ln -s /opt/python3.6/bin/virtualenv /usr/bin/virtualenv #/opt/python3.6/bin/virtualenv替换成你找到路径

5、创建虚拟环境,并命名

irtualenv --no-site-packages venv #venv是虚拟环境的名称

6、激活进入虚拟环境

source venv/bin/activate

7、退出

deactivate

8、其他命令

worken #查看虚拟环境目录

workon venv2 #切换虚拟环境

rmvirtualenv venv #删除虚拟环境

4.安装uwsgi

1、安装

pip3 install uwsgi

2、创建软路由

ln -s /opt/python3.6/bin/uwsgi /usr/bin/uwsgi

3、配置

路径:/opt/rpa_server/server_uwsgi.ini
[uwsgi]

# Django-related settings
# the base directory (full path)
chdir           = /opt/rpa_server
# Django‘s wsgi file
module          = rpa_server.wsgi
enable-threads = true
# process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 1
threads         = 10
# the socket (use the full path to be safe
socket          = 0.0.0.0:8080
#http            = 0.0.0.0:9000
# ... with appropriate permissions - may be needed
# chmod-socket    = 664
# clear environment on exit
vacuum          = true

home             = /root/venv
daemonize        = /opt/rpa_server/maple_uwsgi.log
启动
uwsgi --ini  server_uwsgi.ini
#杀死进程
ps -A|grep uwsgi

kill -9 uwsgi的进程id

5.安装nginx

1、安装

yum install epel-release -y

yum install nginx -y

2、配置

路径:/etc/nginx/conf.d/rpa_server.conf
upstream rpa {
    server 0.0.0.0:8080; # for a web port socket (we‘ll use this first)
}

server {
        listen       8000;
        server_name  ;
        #client_max_body_size 75M;
        access_log logs/rpa_server_access.log main;


        location / {
        uwsgi_pass rpa;
        include /etc/nginx/uwsgi_params;
        }

        location /static {
            alias /opt/rpa_server/static;
        }

        error_page 400 403 404 405 505 500 501 502 503 504 /404.html;
        location = /404.html {
                root    /opt/rpa_server/templates/;
}
}

3、启动

启动
systemctl start nginx
停止
systemctl stop nginx
重启
systemctl restart nginx
查看状态
systemctl status nginx

 

部署django+uwsgi+Virtualenv+nginx+supervisor详细步骤

标签:comment   soc   ted   tar   out   依赖   com   zip   编译   

原文地址:https://www.cnblogs.com/angelyan/p/12919941.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!