1:下载python
https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
2:安装依赖环境
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
3:解压python.tar包
tar -xcf 包名
4:释放编译脚本文件到指定目录:
./configure --prefix=/opt/python3
5:编译
make
6:安装到指定路径
make install /opt/python3
7:配置环境变量
PATH=$PATH:/opt/python3/bin
这只是单次生效,为了永久生效需要写入etc/profile PATH=$PATH:/opt/python3/bin
8:读取配置文件,使得环境变量生效
source /etc/profile
安装django
1:下载django包
pip3 install django==1.11.15
2:创建django项目
django-admin startproject mysite
3:创建app
django-admin startapp app01
4.在mysite中找到manager.py启动django,修改settings.py 允许外部访问
ALLOWED_HOSTS = ["*"]
5.启动django
python3 manage.py runserver 0.0.0.0:8000