-
升级python版本至2.7
[root@erhui1 ~]# python -V Python 2.6.6 [root@erhui1 ~]# wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz [root@erhui1 ~]# yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel [root@erhui1 ~]# tar -zxf Python-2.7.13.tgz [root@erhui1 ~]# cd Python-2.7.13 [root@erhui1 Python-2.7.13]# ./configure --prefix=/usr/local/python2.7 [root@erhui1 Python-2.7.13]# make && make install [root@erhui1 Python-2.7.13]# mv /usr/bin/python /usr/bin/python.bak [root@erhui1 Python-2.7.13]# ln -s /usr/local/python2.7/bin/python /usr/bin/python
-
修改yum配置,还原至2.6
[root@erhui1 Python-2.7.13]# vim /usr/bin/yum #!/usr/bin/python2.6
-
安装easy_install和pip
[root@erhui1 ~]# wget https://pypi.python.org/packages/ba/2c/743df41bd6b3298706dfe91b0c7ecdc47f2dc1a3104abeb6e9aa4a45fa5d/ez_setup-0.9.tar.gz#md5=1ac53445a67bf68eb2676a72cc3f87f8 [root@erhui1 ~]# tar -zxf ez_setup-0.9.tar.gz [root@erhui1 ~]# cd ez_setup-0.9 [root@erhui1 ez_setup-0.9]# python ez_setup.py [root@erhui1 ez_setup-0.9]# /usr/local/python2.7/bin/easy_install pip
-
添加环境变量
[root@erhui1 ~]# vim /etc/profile export PATH=/usr/local/python2.7/bin:$PATH [root@erhui1 ~]# source /etc/profile [root@erhui1 ~]# echo $PATH /usr/local/python2.7/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
-
安装django
[root@erhui1 ~]# pip install django [root@erhui1 ~]# django-admin --version 1.11.4
-
创建一个项目
[root@erhui1 ~]# django-admin startproject hellodjango [root@erhui1 ~]# cd hellodjango/ [root@erhui1 hellodjango]# python manage.py runserver 0.0.0.0:8000
-
修改setting允许访问的IP
[root@erhui1 hellodjango]# vim hellodjango/settings.py ALLOWED_HOSTS = ['*']
-
在浏览器中访问 http://192.168.10.107:8000