python-Centos7环境准备

  • 安装python
  1. 安装python相关依赖  
yum -y install openssl-devel readline-devel unzip

    2.下载python 源码包(下载最新版本)      

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

     3.编译安装python

tar -xzf Python-3.6.2.tgz
cd Python-3.6.2
./configure --prefix=/usr/local/python36
make
make install

           4.配置pip

sudo tee /etc/pip.conf <<-'EOF'
[global]
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com
[list]
format=columns
EOF

             5.配置virtualenv

sudo /usr/local/python36/bin/pip3 install virtualenv
  • 安装django
  1. 初始化env环境
mkdir ~/mushi/usr/local/python36/bin/virtualenv ~/mushi/env

         2.django版本得选择

Django version Python versions
1.8  2.7, 3.2 (until the end of 2016), 3.3, 3.4, 3.5
1.9, 1.10 2.7, 3.4, 3.5
1.11  2.7, 3.4, 3.5, 3.6
2.0 3.5+

           3.安装django1.11

source ~/mushi/env/bin/activate
pip install "django>=1.11"
pip install ipython

 

  • 安装数据库

            1.下载rpm源及安装

             

sudo rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-
5.noarch.rpm
sudo yum install -y mysql mysql-server mysql-devel zlib-devel
source ~/mushi/env/bin/activate
pip install pymysql

             2.修改配置

 

[mysqld]
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8

              3.启动服务

systemctl start mysqld

 

posted @ 2021-01-04 17:04  李家琦  阅读(70)  评论(0编辑  收藏  举报