Ngnix安装:
Python安装。
下载Python包:
cd /usr
解压:
cd /usr
tar xf Python-3.7.1.tar.xz
配置:
进入python目录
cd Python-3.7.1
安装依赖包插件:
yum -y install gcc-* openssl-* libffi-devel sqlite-devel
开始配置
pwd
/usr/Python-3.7.1

进行配置:
./configure --enable-optimizations --with-openssl=/usr/bin/openssl
编译(共416个包的优化编译 ,需要20分钟):
make -j8

安装,默认安装路路径:/usr/local/lib/python3.7 :
pwd
/usr/Python-3.7.1
make install

测试Python安装成功没有:

因为默认环境Python不友好,所以进行安装iPython包;pip与yum类似, 不过是针对Python的包。 pip 是 Python 包管理理⼯工具,该⼯工具提供了了对Python 包的查找、下载、安装、卸载的功能。
规避pip升级时的一个包配置错误,进入Module的setup,将ssl的三行注释删除:
pwd
/usr/Python-3.7.1
vim Modules/Setup
再次执行
make -j4
make install

升级针对Python3的pip:
pip3 install --upgrade pip

安装iPython
pip3 install ipython

安装成功后,进入测试一下:
ipython3

如果要卸载,可以使用:
安装虚拟环境,便于多个项目管理。
cd ~
pip3 install virtualenv

创建一个虚拟环境:
cd ~
virtualenv -p python3 web
激活虚拟环境:
cd /root/web/bin
source activate
当前面出现web时候,就说明环境生效了:
有了环境就可以安装Django了:
pip3 install django
检查django已经存在:
django-admin.py
用django新建一个项目myfkingweb:
django-admin.py startproject myfkingweb
进入myfkingweb,找到manage.py
cd myfkingweb
设置djangon: 在myfkingweb的setting里面做配置允许访问清单,将allowed_hosts解除注释并且修改为["*"]:
cd /root/myfkingweb/myfkingweb
vim settings.py


在执行下面的开启之前:
为了避免报错:django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).
先给django降级:
给django降级
- 卸载django: pip uninstall django
- pip install django==2.1.
最后,可以开启服务了:
python manage.py runserver 你的ip:3389
这个开启方法会出出现报错:
Error: That IP address can't be assigned to.

用正确姿势开启:
python manage.py runserver 0:3389
再次访问:

最后注意,不要Ctrl+C退出虚拟机,否则就无法访问了。