CentOS Linux> [root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# uname -r
3.10.0-514.el7.x86_64
[root@localhost ~]# uname -m
x86_64 2、安装python
python2.7.5已经搭建好了
[root@localhost ~]# python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 2、安装pip
[root@localhost ~]# pip -V
pip 9.0.1 from /usr/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7) 3、安装setuptools
[root@localhost ~]# yum -y install setuptools 4、安装Django环境
[root@localhost ~]# easy_install django
或者[root@localhost ~]# pip install django 5、测试django是否安装成功
[root@bogon setuptools-36.5.0]# django-admin --version
1.11.5
或者
[root@bogon setuptools-36.5.0]# python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.get_version()
'1.11.5'
【更新地址】http://doublelinux.blog.51cto.com/12300166/1965832
================================================================================================ 二、django使用
================================================================================================ 1、使用Django创建一个名为helloworld的项目
[root@bogon setuptools-36.5.0]# cd /home/qiu/
[root@bogon qiu]# django-admin startproject helloworld
[root@bogon qiu]# ls
helloworld 2、运行项目helloworld
[root@bogon qiu]# cd helloworld/
[root@bogon helloworld]# ls
helloworld manage.py
[root@bogon helloworld]# python manage.py runserver 192.168.255.128:8000
Performing system checks...
System check> You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
September 16, 2017 - 06:27:28
Django version 1.11.5, using settings 'helloworld.settings'
Starting development server at http://192.168.255.128:8000/
Quit the server with CONTROL-C. 3、防火墙和selinux设置
[root@bogon hello]# systemctl stop firewalld
[root@bogon hello]# setenforce 0 4、浏览器中访问
出现问题 5、解决问题
[root@bogon qiu]# cd /home/qiu/helloworld/
[root@bogon helloworld]# ls
db.sqlite3 helloworld manage.py
[root@bogon helloworld]# cd helloworld/
[root@bogon helloworld]# ls
__init__.py __init__.pyc settings.py settings.pyc urls.py urls.pyc wsgi.py wsgi.pyc
[root@bogon helloworld]# vim settings.py
将ALLOWED_HOSTS = []修改为ALLOWED_HOSTS = ['*']