一、安装python基础环境1.安装各类基础模块yum install gcc-c++ wget openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel libxml* -y2.安装python3环境2.1)下载python3.6包wget http...
一、安装python基础环境
1.安装各类基础模块
yum install gcc-c++ wget openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel libxml* -y
2.安装python3环境
2.1)下载python3.6包
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
2.2)解压、安装python3
tar -zxvf Python-3.6.3.tar.gz && cd Python-3.6.3
./configure --prefix=/usr/local/python3 && make && make install
3.3)python3相关命令添加系统环境中
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
2.python3安装django和uwsgi模块
pip3 install django==1.11.10
pip3 install uwsgi
3.写好django项目打包上传到服务器,修改setting.py
ALLOWED_HOSTS = ['*',] #允许所有ip访问django项目
DEBUG = False #关闭DEBUG模式
STATIC_ROOT='/home/CMS/mysite/static/' #配置静态文件存放的目录
4.把django项目中的静态文件分离出来
python3 manage.py collectstatic
二、配置nginx访问uwsgi
?server {
??????? listen?????? 80;
??????? server_name? localhost; ??????? #charset koi8-r; ??????? #access_log? logs/host.access.log? main; ??????? #location / {
??????? #??? root?? html;
??????? #??? index? index.html index.htm;
??????? #} ? #设置代理访问
??????? location / {
???????? include uwsgi_params;
???????? uwsgi_pass 127.0.0.1:8080;
???????? uwsgi_read_timeout 30;
??????? } ? 三、 使用nginx代理获取静态文件 location /static {
??????????????? autoindex on;
??????????????? alias /home/CMS/mysite/static/;? #静态文件访问路径
??????????????? } 四、重启nginx 和启动django项目 python3 manage.py? runserver 0.0.0.0:8080 #重启django项目 systemctl? restart nginx.service #重启nginx ?
本文标题为:django+nginx+python3 生产环境部署
- CentOS7 安装 Python3.6 2023-09-04
- 在centos6.4下安装python3.5 2023-09-04
- windows安装python2.7.12和pycharm2018教程 2023-09-03
- python线程池ThreadPoolExecutor与进程池ProcessPoolExecutor 2023-09-04
- Python Pandas如何获取和修改任意位置的值(at,iat,loc,iloc) 2023-08-04
- Python之路-Python中的线程与进程 2023-09-04
- python中defaultdict用法实例详解 2022-10-20
- Python实现将DNA序列存储为tfr文件并读取流程介绍 2022-10-20
- Python 保存数据的方法(4种方法) 2023-09-04
- python中列表添加元素的几种方式(+、append()、ext 2022-09-02