Step By Step设置Django

想在自己的Ubuntu Server虚拟机上搭建一个LAMP玩玩,P用Python,使用Django和PostgreSQL,在网上搜了半天,大部分文章都是很粗略,因此自己整理一个Step By Step,作为备忘

Install Django

下载最新的Django,然后解压安装
wget https://www.djangoproject.com/download/1.5.1/tarball/
tar xzvf index.html
sudo python setup.py install

Install WSGI

安装Apache2
sudo aptitude install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert

打开浏览器访问http://<your machine ip>/ 如果你可以看到Apache2的欢迎网页,那就代表成功了

sudo aptitude install libapache2-mod-wsgi
sudo service apache2 restart

Install Postgresql

sudo apt-get install postgresql

安装完成后,需要设置默认用户 postgres的密码,并且创建一个数据库,后面会用到。这些命令适用于Ubuntu12.04上的Postgres9.1。

输入一下命令,进入Postgresql的界面更改密码

sudo -u postgres psql
在界面下输入下面的命令然后输入新密码

\password

Then we connect as 'postgres'. The -h localhost part is important: it tells the psql client that we wish to connect using a TCP connection (which is configured to use password authentication), and not by a PEER connection (which does not care about the password).

psql -U postgres -h localhost

I really wish they'd document all this in a more newcomer friendly fashion, instead of requiring a mandatory Google search and frustration.

login to the sample db to check your credential

psql -h localhost -U postgres -d mydb



Create first Django site

在这里,我跟着Django网站的教程,一步一步的完成,暂时不重复这个过程了,可以在下面的链接找到内容。回头会整理一下比较重要的命令放在这里

https://docs.djangoproject.com/en/1.5/intro/tutorial01/


Please take below as reference if you can't execute "python manage.py syncdb"

input \dt to check table list


Reference

下面是我设置的时候参考的一些比较有用的页面

https://help.ubuntu.com/community/PostgreSQL

https://www.digitalocean.com/community/articles/installing-django-on-ubuntu-12-04--4

https://www.digitalocean.com/community/articles/installing-mod_wsgi-on-ubuntu-12-04

https://docs.djangoproject.com/en/1.5/intro/tutorial01/


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值