在 /opt目录中安装
cd /opt
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.7/Python-3.6.7.tar.xz xz -d Python-3.6.7.tar.xz tar -xf Python-3.6.7.tar #解压缩,生成一个python源码文件夹
3.进入python源码文件夹
cd Python-3.6.7
4.进行编译安装,编译三步
1.第一步 ./configure --prefix=/opt/python36/ --prefix 参数解释:指定python36安装的位置 2.第二步 make 3.第三步 ,此时就开始安装python3软件 make install
5.进入python36安装目录 ,检查bin目录
ll -h
6.配置python3的环境变量 PATH
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
1.安装django模块 pip3 install -i https://pypi.douban.com/simple django 2.升级pip pip3 install --upgrade pip 3.通过命令创建django项目 django-admin startproject crm django-admin startapp app01 关闭防火墙 iptables -F 安装tree yum install tree -y