Mar 7, 2012

Setting up Django on ubuntu



Here are the steps to setup Django on Amazon EC2 server:
The image is ubuntu-maverick-10.10-amd64-server-20101225
Choose the ebs one, otherwise you will lose everything after you shutdown your server
  1. sudo apt-get update
  2. sudo apt-get install apache2
  3. wget http://www.djangoproject.com/download/1.3/tarball/
  4. mv index.html Django-1.3.tar.gz
  5. tar xzvf Django-1.3.tar.gz
  6. cd Django-1.3
  7. sudo python setup.py install
  8. sudo  apt-get install libapache2-mod-wsgi
  9. create "/home/ubuntu/mysite/django-server.wsgi"
  10. import os, sys
    sys.path.append('/home/ubuntu/')
    sys.path.append('/home/ubuntu/mysite')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
  11. sudo /etc/init.d/apache2 start
  12. cd  /etc/apache2/sites-available
  13. sudo cp  default mysite
  14. edit "mysite"
  15. Listen 8000
    <VirtualHost *:8000>
            WSGIScriptAlias / /home/ubuntu/mysite/django-server.wsgi
            WSGIDaemonProcess server1piece user=www-data group=www-data processes=1 threads=10
            ServerAdmin webmaster@localhost
            DocumentRoot /home/ubuntu/
            Alias /static/admin/ /home/ubuntu/Django-1.3/django/contrib/admin/media/
  16. a2ensite mysite
  17. sudo /etc/init.d/apache2 reload
  18. sudo /etc/init.d/apache2 restart
  19. cd ~
  20. django-admin startproject mysite
  21. cd ~/mysite
  22. django-admin startapp myapp 
  23. python manage.py runserver 0.0.0.0:8000

0 comments:

 
TEMPLATE HACKS AND TWEAKS BY [ METAMUSE ] BLACKCAT 1.1
/scripts/shBrushJScript.js'/>