1、安装Django
#pip方式安装django [[email protected] ~]$ python -V Python 3.5.1 [[email protected] ~]$ [[email protected] ~]$ sudo pip install django #安装完成后,运行python进入交互式模式 [[email protected] ~]$ 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 [[email protected] ~]$ cd /home/xiaomo/source/ [[email protected] source]$ wget https://www.djangoproject.com/m/releases/1.9/Django-1.9.5.tar.gz [[email protected] source]$ sudo tar xf Django-1.9.5.tar.gz [[email protected] source]$ sudo python setup.py install #git安装django的方式我就不演示了
好了,django到此算是安装完成了.
下面来启用django服务
#首先来创建一个项目 [[email protected] local]$ sudo django-admin startproject test01 [[email protected] local]$ tree test01/ test01/ ├── manage.py └── test01 ├── __init__.py ├── settings.py ├── urls.py └── wsgi.py 1 directory, 5 files [[email protected] local]$ #创建一个项目会生成以上几个文件 #启动django服务 [[email protected] test01]$ cd test01 [[email protected] 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. [[email protected] test01]$ sudo ss -lnpt | grep 8000 LISTEN 0 10 127.0.0.1:8000 *:* users:(("python",pid=2073,fd=5)) [[email protected] test01]$ #好了,django已经启动成功了,可以在浏览器输入
#django服务已经能正常运行访问了。
#在此鼓励一下自己的劳动成果!
时间: 2024-10-05 23:36:28