1.解决python编译安装所需的软件依赖
yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y
2.下载python3源码包
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
xz -d Python-3.6.5.tar.xz
tar -xvf Python-3.6.5.tar # 解压缩,生成一个python源码文件夹
3.进入python3源码文件夹
cd Python-3.6.5/
4.进行编译安装
# 第一步 ./configure --prefix=/opt/python36/ # 第二步 make #第三步 make install # make && make install 第二、第三步并作一步执行
5.进入python36源码目录,检查bin目录
6.配置python3的环境变量
# 1.取出当前的path变量 echo $PATH # 2.取出python3的bin目录到PATH中 PATH=” /opt/python36/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin” # 3.将环境变量写入到全局配置文件/etc/profile vim /etc/profile # 4.写入以下代码,在最底行配置 PATH=” /opt/python36/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin” # 5.读取配置文件,加载变量生效 source /etc/profile
7.安装django,运行django
pip3 install -i https://pypi.douban.com/simple django # 安装的是默认版本的django 187 pip3 install -i https://pypi.douban.com/simple django==1.11.9 # 安装指定版本 188 pip3 install --upgrade pip 189 pip3 list 190 cd /opt 191 django-admin startproject crm 192 ls 193 cd crm 194 ls 195 python3 manage.py runserver 198 iptables -L 199 iptables -F # 关闭防火墙 # python3 manage.py runserver 0.0.0.0:8000 202 python3 manage.py runserver 192.168.40.145:8000