一、Mysql
1、安装服务端
yum install mariadb-server -y mariadb-server.x86_64 1:5.5.68-1.el7 # 版本
2、安装客户端
yum install mariadb -y # 软件包 1:mariadb-5.5.68-1.el7.x86_64 已安装并且是最新版本
3、服务配置
4、帐号初始化
二、Redis
三、Python
四、虚拟环境
五、拉取代码和配置
六、仅用uwsgi部署
1、激活虚拟环境并安装uwsgi
source /envs/nb/bin/activate pip install uwsgi
- 命令启动
uwsgi --http :8001 --chdir /data/django-project/day06/ --wsgi-file day06/wsgi.py --master --processes 1 --static-map /static=/data/django-project/allstatic
# 指令介绍 uwsgi 启动指令 --http 支持http协议 --chdir 进入项目目录,与manage.py同级 --wsgi-file 找到wsgi.py文件 --master 权限为master权限 --processes 进程数量 --static-map 静态文件路径
- 文件启动
2、项目根目录创建 day06_uwsgi.ini,和manage.py同级
# terminal
touch day06_uwsgi.ini
vim day06_uwsgi.ini
3、进入ini文件,加入如下配置
# day06_uwsgi.ini [uwsgi] socket = 127.0.0.1:8001 #ip可是本机,也可以是0.0.0.1任意机器都可以请求 chdir = /data/django-project/day06/ wsgi-file = day06/wsgi.py processes = 1 static-map = /static=/data/django-project/allstatic virtualenv = /envs/day06/
4、执行启动命令
source /envs/nb/bin/activate uwsgi --ini day06_uwsgi.ini # 程序会一直挂在前台 uwsgi --ini day06_uwsgi.ini & # 加一个"&"可以后台运行
七、nginx+uwsgi部署
1、利用nginx做反向代理和处理静态文件。
yum install nginx -y
修改nginx.conf配置文件:
vim /etc/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 4096; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. # include /etc/nginx/conf.d/*.conf; upstream django { server 127.0.0.1:8001; } server { listen ; listen [::]:80; # server_name ip、域名、localhost是处理本机的请求 server_name day06.pythonav.com; # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; location /static { alias /data/www/allstatic/; } location / { uwsgi_pass django; include uwsgi_params; } } }
2、修改uwsgi配置(day06_uwsgi):
[uwsgi] socket = 127.0.0.1:9000 chdir = /data/www/xxxxx/ wsgi-file = day06/wsgi.py processes = 4 virtualenv = /envs/video_killer/
3、接下来就需要启动uwsgi和nginx:
nginx
# 直接启动 systemctl start nginx # 或者设置开机自启动 systemctl enabl
uwsgi
uwsgi --ini day06_uwsgi.ini &