/usr/local/mysql/bin/mysql -h 127.0.0.1 -p
source /root/BBS.sql
Django + Uwsgi + Nginx 实现生产环境部署
安装nginx,先安装nginx的依赖
yum -y install gcc gcc-c++ make tar pcre pcre-devel zlib zlib-devel openssl openssl-devel
1>.环境探测 ./configure 指定参数
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_v2_module
2>.编译make
3>.安装make install
linux安装
python3.6安装:
tar -zxf Python-3.6.8.tgz
配置安装信息
./configure --prefix=/usr/local/python3/
编译安装
make && make install
配置环境变量,新建文件
vim /etc/profile.d/python3.sh
export PATH=$PATH:/usr/local/python3/bin/
环境变量生效:
source /etc/profile
source /etc/profile.d/python3.sh
验证
python3
Python 3.6.8 (default, Jan 29 2019, 10:04:09)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
/usr/local/python3/bin/pip3 install uwsgi
python部署参考链接:
pip3 install requests
pip3 install Django==1.11.9
pip3 install pymysql
pip3 install Pillow
pip3 install beautifulsoup4
pip3 install paramiko
pip3 install lxml
测试 Django
python3 manage.py runserver 192.168.10.5:8000
进入Django项目测试uwsgi
uwsgi --http 192.168.10.5:8080 --file BBS_new/wsgi.py --static-map=/static=static
进入script目录,启动uwsgi
/usr/local/python3/bin/uwsgi --ini uwsgi.ini
Django + Uwsgi 部署参考:
/usr/local/mysql/bin/mysql -h 127.0.0.1 -p
mysql -uroot -p BBS -h 127.0.0.1 < BBS.sql
uwsgi.ini
# uwsig使用配置文件启动
[uwsgi]
# 项目目录
chdir=/root/BBS_new/
# 指定项目的application
module=BBS_new.wsgi:application
# 指定sock的文件路径
socket=/root/script/uwsgi.sock
# 进程个数
workers=5
pidfile=/root/script/uwsgi.pid
# 指定IP端口
http=192.168.10.5:8080
# 指定静态文件
static-map=/static=/root/BBS_new/static
# 启动uwsgi的用户名和用户组
uid=root
gid=root
# 启用主进程
master=true
# 自动移除unix Socket和pid文件当服务停止的时候
vacuum=true
# 序列化接受的内容,如果可能的话
thunder-lock=true
# 启用线程
enable-threads=true
# 设置自中断时间
harakiri=30
# 设置缓冲
post-buffering=4096
# 设置日志目录
daemonize=/root/script/uwsgi.log
访问地址:
错误解决方法:
数据库版本不一致:
ERROR 1273 (HY000) at line 25: Unknown collation: 'utf8mb4_0900_ai_ci'
解决方法:
查找:utf8mb4_0900_ai_ci,全部替换为:utf8_general_ci
查找:utf8mb4 全部替换为 utf8