Mar 30, 2012

How To: Install lxml on Ubuntu

sudo apt-get install libxml2-dev
sudo apt-get install libxslt1-dev
sudo apt-get install python2.6-dev
easy_install --allow-hosts=lxml.de,*.python.org lxml

List of commands for MySql and Django


mysqladmin.exe -u root -p create myapp
python manage.py syncdb
mysql -u root -p
sudo /etc/init.d/apache2 restart

Mar 18, 2012

OpenSSH configuration file

Putty is a lovely ssh program, but I love console2 even more.

To use ssh to connect to Amazon EC2 server, you need cygwin to run openssh in Windows environment.
The command is (under cygwin):

ssh -i MySite.pem ubuntu@xxx.amazonaws.com
To make the command shorter, create "~/.ssh/config"
and add:

Host MySite
User ubuntu
Port 22
IdentityFile ~/.ssh/MySite.pem
HostName xxx.amazonaws.com

To connect, just type:

ssh MySite

Mar 16, 2012

Setting selective sync of Dropbox on Amazon EC2 server

Dropbox provides an easy to backup the server. However, the default setting synchronizes all of the files to the server, which is very annoying.
I don't want all of my personal stuff to be stored in a public server.

In order to select the file which you would like to sync, download dropbox.py
and type the following commands in the terminal:
python dropbox.py exclude add ~/Dropbox/*
python dropbox.py exclude remove ~/Dropbox/<folder-to-sync> 

The first command excludes all of files from your dropbox.
The second one adds the folder which is going to be synchronized.

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

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