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

 

转载于:https://www.cnblogs.com/hanlu5016/p/7872776.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值