1、安装Django
#pip方式安装django [xiaomo@Arch-XIAOMO ~]$ python -V Python 3.5.1 [xiaomo@Arch-XIAOMO ~]$ [xiaomo@Arch-XIAOMO ~]$ sudo pip install django #安装完成后,运行python进入交互式模式 [xiaomo@Arch-XIAOMO ~]$ python Python 3.5.1 (default, Mar 3 2016, 09:29:07) [GCC 5.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import django >>> django.VERSION (1, 9, 5, ‘final‘, 0) >>> #安装版本为django-1.9.5 #源码包安装django [xiaomo@Arch-XIAOMO ~]$ cd /home/xiaomo/source/ [xiaomo@Arch-XIAOMO source]$ wget https://www.djangoproject.com/m/releases/1.9/Django-1.9.5.tar.gz [xiaomo@Arch-XIAOMO source]$ sudo tar xf Django-1.9.5.tar.gz [xiaomo@Arch-XIAOMO source]$ sudo python setup.py install #git安装django的方式我就不演示了
好了,django到此算是安装完成了.
下面来启用django服务
#首先来创建一个项目 [xiaomo@Arch-XIAOMO local]$ sudo django-admin startproject test01 [xiaomo@Arch-XIAOMO local]$ tree test01/ test01/ ├── manage.py └── test01 ├── __init__.py ├── settings.py ├── urls.py └── wsgi.py 1 directory, 5 files [xiaomo@Arch-XIAOMO local]$ #创建一个项目会生成以上几个文件 #启动django服务 [xiaomo@Arch-XIAOMO test01]$ cd test01 [xiaomo@Arch-XIAOMO test01]$ sudo python manage.py runserver Performing system checks... System check identified no issues (0 silenced). You have unapplied migrations; your app may not work properly until they are applied. Run ‘python manage.py migrate‘ to apply them. April 29, 2016 - 04:45:57 Django version 1.9.5, using settings ‘test01.settings‘ Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. [xiaomo@Arch-XIAOMO test01]$ sudo ss -lnpt | grep 8000 LISTEN 0 10 127.0.0.1:8000 *:* users:(("python",pid=2073,fd=5)) [xiaomo@Arch-XIAOMO test01]$ #好了,django已经启动成功了,可以在浏览器输入
#django服务已经能正常运行访问了。
#在此鼓励一下自己的劳动成果!
本文出自 “逢场做戏。” 博客,请务必保留此出处http://xiaofengmo.blog.51cto.com/10116365/1768958
原文地址:http://xiaofengmo.blog.51cto.com/10116365/1768958