zoukankan      html  css  js  c++  java
  • lnmp下django学习

    [1]  安装一些软件包    .
    # install from EPEL
    [root@linuxprobe ~]# yum --enablerepo=epel -y install python-virtualenv
    
    [2]  在Virtualenv环境下安装Django,它可以为任何普通用户,这里使用root,建议使用普通用户。   
    #deactivate                # 退出当前虚拟环境
    #workon [虚拟环境名称]       # 使用某个虚拟环境
    #rmvirtualenv [虚拟环境名称] # 删除某个虚拟环境
    #lsvirtualenv              # 列出所有虚拟环境
    [root@linuxprobe ~]$ virtualenv venv [root@linuxprobe ~]$ cd ~/venv [root@linuxprobe venv]$ source bin/activate (venv)[root@linuxprobe venv]$ pip install django Downloading/unpacking django Downloading Django-1.10.2.tar.gz (7.7MB): 7.7MB downloaded Running setup.py egg_info for package django no previously-included directories found matching 'django/contrib/admin/bin' warning: no previously-included files matching '__pycache__' found anywhere in distribution Installing collected packages: django Running setup.py install for django no previously-included directories found matching 'django/contrib/admin/bin' warning: no previously-included files matching '__pycache__' found anywhere in distribution changing mode of build/scripts-2.7/django-admin.py from 644 to 755 changing mode of /root/venv/bin/django-admin.py to 755 Installing django-admin script to /root/venv/bin Successfully installed django Cleaning up... # 上面的警告不是问题 (venv)[root@linuxprobe venv]# django-admin --version 1.10.2 # 退出virtualenv (venv)[root@linuxprobe venv]# deactivate


    [3] 创建测试项目
    [root@linuxprobe ~]$ cd ~/venv 
    [root@linuxprobe venv]$ source bin/activate
    # create "testproject"
    (venv)[root@linuxprobe venv]$ django-admin startproject testproject 
    (venv)[root@linuxprobe venv]$ cd testproject 
    # configure database (default is SQLite)
    (venv)[root@linuxprobe testproject]$ python manage.py migrate
    Operations to perform:
      Apply all migrations: admin, auth, contenttypes, sessions
    Running migrations:
      Applying contenttypes.0001_initial... OK
      Applying auth.0001_initial... OK
      Applying admin.0001_initial... OK
      Applying admin.0002_logentry_remove_auto_add... OK
      Applying contenttypes.0002_remove_content_type_name... OK
      Applying auth.0002_alter_permission_name_max_length... OK
      Applying auth.0003_alter_user_email_max_length... OK
      Applying auth.0004_alter_user_username_opts... OK
      Applying auth.0005_alter_user_last_login_null... OK
      Applying auth.0006_require_contenttypes_0002... OK
      Applying auth.0007_alter_validators_add_error_messages... OK
      Applying auth.0008_alter_user_username_max_length... OK
      Applying sessions.0001_initial... OK
    # create admin user
    (venv)[root@linuxprobe testproject]# python manage.py createsuperuser
    Username (leave blank to use 'root'): root
    Email address: root@linuxprobe.org
    Password: 
    Password (again): 
    Superuser created successfully.
    # start server
    (venv)[root@linuxprobe testproject]# python manage.py runserver 0.0.0.0:8000
    Performing system checks...
    
    System check identified no issues (0 silenced).
    October 31, 2016 - 14:03:16
    Django version 1.10.2, using settings 'testproject.settings'
    Starting development server at http://0.0.0.0:8000/
    Quit the server with CONTROL-C.

    [4]从客户端计算机访问“http://(服务器的主机名或IP地址):8000 /”。如果以下网站正常显示,表示启动成功。

    django学习推荐:http://www.cnblogs.com/feixuelove1009/p/5910384.html

  • 相关阅读:
    pytest插件
    jmeter中beanshell postprocessor结合fastjson库提取不确定个数的json参数
    简单的介绍一下jmeter各个元件的执行顺序
    强缓存的原理
    Win10设置服务开机自启
    Tomcat部署Web应用程序
    PHP伪协议
    PHP配置文件说明
    PHP-XDebug配置
    Ubuntu_apt命令
  • 原文地址:https://www.cnblogs.com/hanlu5016/p/7872776.html
Copyright © 2011-2022 走看看