sh 配置CentOS开发环境:Django + Python3.6 + Nginx + MySQL
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 配置CentOS开发环境:Django + Python3.6 + Nginx + MySQL相关的知识,希望对你有一定的参考价值。
# 创建新用户(自定义)
useradd sdf
cd /home/sdf/
# 在新用户下配置Python虚拟环境
python3 -m venv my_env # 不再需要额外装virtualenv
# python3 -m venv myenv --system-site-packages 用这种方式可以直接得到系统自带的包
source my_env/bin/activate
pip install --upgrade pip
# 一些常用的包
pip install django==1.11
pip install mysqlclient
pip install python-decouple
pip install dj-database-url==0.4.2
pip install django-widget-tweaks==1.4.1
pip install Markdown==2.6.9
pip install python-decouple==3.1
pip install pytz==2017.2
pip install gunicorn
pip install psycopg2
######### Preparing the System
# Let’s first make sure that yum is up to date
yum -y update
# yum-utils, a collection of utilities and plugins that extend and supplement yum
yum -y install yum-utils
# Finally, we’ll install the CentOS Development Tools,
# which are used to allow you to build and compile software from source code:
yum -y groupinstall development
yum install lrzsz -y
######### 安装 Python 3.6.2
# 安装依赖包
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel...
# 下载 Python 3.6.2
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
# 由于 Python 3.6.2 的编译需要编译环境,故需安装 gcc
yum -y install gcc
# 解压 Python 3.6.2 并安装在 /usr/local/python3 目录下
mkdir /usr/local/python3
tar -xvJf Python-3.6.2.tar.xz
cd Python-3.6.2
./configure --prefix=/usr/local/python3
make && make install
# 创建软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
######### 安装 MySQL
yum install mysql-devel
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum -y install mysql-community-server
pip3 install --upgrade pip
pip3 install mysqlclient
service mysql restart
######### 安装 Nginx
以上是关于sh 配置CentOS开发环境:Django + Python3.6 + Nginx + MySQL的主要内容,如果未能解决你的问题,请参考以下文章
CentOS7 + Python3 + Django(rest_framework) + MySQL + nginx + uwsgi 部署 API 开发环境, 记坑篇
sh centos安装开发环境
centos配置环境变量
Centos7下Django开发环境搭建
centos+apache+python34+django+mod_wsgi 开发环境搭建
阿里云 Centos7 部署 Django 项目