Category Archives: Ubuntu

Simple Django install on Amazon EC2

I set up an amazon ec2 instance this weekend and as I knew I’d bedoing it again I noted the steps performed. Hopefully they’ll be of use to someone.

Firstly you need to set up an EC2 account. I’d also recommend downloading ElasticFox(XPIinstaller) which makes it easier to manages instances, volumes andelastic IPs. Also install the EC2API command line tools so you can start and stop instances etc.

The following guide is what I did to set up an Ubuntu 9.10 instance with EBS volume attached and a basic django install running. Bear the following in mind when reading the guide:

  • References to are to my elastic IP address that I set up using Elasticfox so it will be different for you.
  • “philroche” is the username I use so I’d hope you’d be changing that.
  • pk-XXXXXXXXXX.pem is the private key from the x509 certificate that was generated when creating my account
  • cert-XXXXXXXXXX.pem is the certificate file from the x509certificate that was generated when creating my account
  • i-d820f7af is the instance ID assigned to my instance – this will be different for you
  • is the public DNS for the instance I created. This will also be different for you.
  • philrocheEC2Europe.pem is the private key for the generated key pair which was generated during account set up
  • The AMI I used (ami-97e4cfe3) has a user “ubuntu” already created that is used for initial login
  • djangoreporting ( a simple django app that I used to test the set up.

Seting up Ubuntu 9.10 django install on EC2

  • AMI id = ami-97e4cfe3
  • instance id = i-d820f7af
  • ip address = – I created an elastic IP and assigned it to my instance
  • public dns name
  • login = ssh -i philrocheEC2Europe.pem ubuntu@ (philrocheEC2Europe.pem is private key generated key pair)
  • enable root user = sudo passwd root
  • change to root user = su
  • add new user = adduser philroche
  • add philroche to sudoers list = visudo
  • add the following to file = philroche ALL=(ALL) NOPASSWD:ALLcheck
  • Disable Password-based Login = nano /etc/ssh/sshd_config
    • check for PasswordAuthentication no
  • check root login is disabled
    • PermitRootLogin no
    • AllowUsers philroche ubuntu
  • restart sshd to take affect = /etc/init.d/ssh restart
  • create .ssh directory for philroche user to store public key =mkdir /home/philroche/.ssh
  • generate key pair LOCALLY in your users’ .ssh directory = ssh-keygen -b 1024 -f philroche -t dsa
  • make temp directory to upload public key = mkdir /home/philroche/tmp
    • chmod 777 /home/philroche/tmp
  • upload public key from LOCAL .ssh directory = scp -i philrocheEC2Europe.pem /home/philroche/.ssh/ ubuntu@
  • login again and authorize this key = ssh -i philrocheEC2Europe.pem ubuntu@
  • authorize the philroche user with uploaded public key = cat/home/philroche/tmp/ >> /home/philroche/.ssh/authorized_keys
    • chown philroche:philroche /home/philroche/.ssh
    • chmod 700 /home/philroche/.ssh
    • chown philroche:philroche /home/philroche/.ssh/authorized_keys
    • chmod 600 /home/philroche/.ssh/authorized_keys
  • Delete the tmp directory = rm -rf /home/philroche/tmp
  • Now login as new user (philroche) = ssh philroche@
  • Install require software = su
    • apt-get update
    • apt-get install apache2 python2.5 mysql-server mysql-client libapache2-mod-wsgi python-mysqldb python-setuptools subversion
    • NOTE – You will be prompted for mysql root password
  • enable the modules
    • a2enmod rewrite
    • a2enmod wsgi
  • make sure wsgi is using python2.5
    • rm /usr/lib/apache2/modules/
    • ln -s /usr/lib/apache2/modules/ /usr/lib/apache2/modules/
  • add virtual hosts by name support to apache
    • nano /etc/apache2/apache2.conf
    • make sure ‘NameVirtualHost *’ is present
  • install django = easy_install-2.5 django
  • Setting up sample app
    • nano /etc/apache2/sites-available/djangoreporting
    • a2ensite djangoreporting
    • mv /home/philroche/Sites/djangoreporting/reporting /usr/lib/python2.5/site-packages
    • echo ‘/home/philroche/Sites/djangoreporting’ >> /usr/lib/python2.5/site-packages/people_example.pth
    • mysql –user=”root” –password=”%Your root password%”
      • create database djangoreporting;
      • CREATE USER ‘djangoreporting’@’localhost’ IDENTIFIED BY ‘djangoreporting’;
      • GRANT ALL ON djangoreporting.* TO ‘djangoreporting’@’localhost’;
      • exit
  • LOCALLY nano /etc/hosts – add djangoreporting
  • /etc/init.d/apache2 restart python2.5 syncdb –noinput
  • To manage your instance
    • export EC2_HOME=$HOME/Applications/ec2-api-tools-1.3-46266/
    • export PATH=$PATH:$EC2_HOME/bin
    • export JAVA_HOME=/usr/lib/jvm/java-6-sun-
    • exportEC2_PRIVATE_KEY=/home/philroche/EC2InstanceSetUp/pk-XXXXXXXXXX.pem
    • exportEC2_CERT=/home/philroche/EC2InstanceSetUp/cert-XXXXXXXXXX.pem
    • sh ec2-describe-instances –region eu-west-1
    • sh ec2-stop-instances –region eu-west-1 i-d820f7af
    • sh ec2-start-instances –region eu-west-1 i-d820f7af
    • NOTE – when stoppped and restarted you have to re-associate the IP address

Mapping “djangoreporting” to in my hosts file lets methe test the server by accessing http://djangoreporting/

Links of interest:

Ran out space on virtual machine (Virtual Box)

I use VirtualBox OSE for my virtual machines and really love it. I tried to change to the non-free VirtualBox (so I could use USB) but moving from one to the other in Ubuntu was not a simple process and eventually I rolled back (thank Christ for CloneZilla).

I’ve got a Win XP virtual machine with a 10GB hard disk which was getting full so I needed to expand it. The simplest way I found was to use the excellent CloneVDI tool. The tool runs perfectly under wine so I was able to double the size of the disk.

This did not however increase the size of the C drive in Win XP so I installed Partition Magic and resized C to take all available space. Now I’ve got a Win XP virtual machine with tons and tons of space 🙂

Moving to Ubuntu (….kind of)

I’ve signed up for a masters in UCD (Advanced Software Engineering in University College Dublin) starting in December. I’m really looking forward to it and as a treat I bought a new (used) laptop that’ll be just for Uni work. It’s an IBM Thinkpad T43 (Centrino 1.7Ghz and 1GB ram with 40GB HD, Wifi, Bluetooth, PCMCIA, Expresscard and all the other usuals) I bought it on ebay (where else?) for £240 delivered. The build quality is excellent and I’m very happy with it. I’ve got Ubuntu 8.04 running on it and it’s going quite well. I’ve encountered the following problems:

  • I get an “not enough memory” error when I try and hibernate
  • Wireless seems kind of flaky especially with the upgraded NetworkManager, I can’t connect to my Dad’s network and keep getting a 169 IP address but this happens on my Vaio too so I suspect it is the Intel Wireless hardware and my Dad’s DHCP server not playing nice together.
  • I can’t get mobile broadband working (either using the new NetworkManager or UMTSMON)
  • Audio when playing video took a while to get working and had to change from Pulse to the ALSA sound architecture.

Lest not forget that there are millions of positives with Ubuntu, especially the Synaptic package manager and power management.

I’m loving Gnome and I’m trying to find a few cycles to play with MonoDevelop properly. I’ve been trying to get the localising feature in MonoDevelop working with an ASP.NET web application but no joy yet. I can get it working on a command line app though :).

Ubuntu no longer likes to mount me

I started an edgy eft (Ubuntu 6.06) to feisty fawn (Ubuntu 7.04) upgrade at the weekend. All seemed to go well apart from, it no longer likes my fstab file for auto mounting disks. I have my home directory on a different partition and auto mount it using the fstab file. It no longer works. I spent about an hour trying to figure out why but to no avail. I can see the parition in /dev fine (/dev/sda2) but when I mount it – there’s nothing there. I’ll try with a live CD (I have to unplug one of my monitors first). Has anyone had any issues like this?

Extend Your Browser

Tuesday 6th (the day of my presentation) eventually rolled around. Due to a crazy machine rebuild and re-install fest, I only finished writing the presentation at 1:30pm on the day. It went really well, some very good questions at the end. As I mentioned in my previous entry – the description of the presentation was –

Firefox and the Gecko family of browsers are not simply web browsers, they can be extended to provide custom functionality, and used as platforms for building standalone applications. During the presentation I will discuss the anatomy of the Gecko engine and the Firefox browser, extensions and how to create an extension for the Firefox 2.0 browser using Aggreg8 ( ) as an example.

Philip is a 2003 Software Engineering graduate of Dublin City University. He has been working at Karova Ltd for two years, on ecommerce and custom web applications, and now holds the position of Senior Developer. Outside the office, he hacks on Firefox extensions and small Python or Perl based open source projects. He loves C#, XSLT, Python, MySQL, WxPython, SVG, XUL, Gecko, Javascript, RSS, CSS, his Labrador puppy, Ubuntu and Mono.

You can now download my preentation-

In MP3 audio format – (no pen clicking this time 🙂 )
ITWalesExtendingYourBrowserPhilipRoche.MP3 [mp3 31 MB – 1 hour 2 minutes]
PDF of my presentation slides
ExtendingYourBrowser-Slides.pdf [pdf 501 KB]
PDF of my presentation slides – including my notes
ExtendingYourBrowser-Notes.pdf [pdf 548 KB]


Geek resolutions

As it’s new year and my motivation is at an all time low, I think a list of TODOs (or new years resultions) is needed. Some of those listed are techy and some are not but all of them are aimed at improving my life.

I will

  • Finish the new design of this site – as you can see, it’s still a work in progress
  • Comment my code
  • Finish projects I have started
  • Document my code properly
  • Use UML – even if it’s just in my head
  • Move to Ubuntu on my home machine
  • Caption all my photos – all 8500 of them
  • Read all the books I bought
  • Read non-techy books too
  • Cook more
  • Eat less
  • Eat healthier
  • Find some way of feeling healthier that I can actually stick to (Gym is a bit too much commitment)
  • Start to budget my outgoings properly
  • Stop calling my dog “the rodent”
  • Learn that Friday does not have to equal “getpissedday”
  • Stop watching soap operas – comedy series like King of Queens and Scrubs will remain on my Sky+ planner though
  • Contribute to an open source project
  • Help fellow developers more
  • Always keep in mind that I know only a fraction of what I think I know
  • Be in a good mood
  • Write another useful Firefox extension that uses a custom XPCOM component
  • Use Patterns in code more
  • Stop driving like an idiot just so I can get home quicker
  • Go to Ireland to see my friends and family more
  • Go to the summer house in Norway
  • Save money
  • And finally – keep this blog up to date

There’s quite a few there so I think it’s more of a two year plan. I have been working on an eight year plan with Gill too, but it’s still a bit up in the air but very exciting – as along as all goes well –

I will also (I thought of some more)

  • Move to IMAP instead of POP email
  • Backup more
  • Learn how to use SVN properly
  • Go to LinuxWorld in London (as long as it’s not on Gill’s birthday like last year)
  • Get a whiteboard at home
  • ……..I’ll add some more as I think of them

instLux saved my bacon

instLux, installing linux on a machine with no cd or floppy drive

I was very bored of my toshiba libretto L5 as WinXP was getting crazy slow on it so I never bothered to use it. I wanted to put Ubuntu on it but the live cd or the install would not recognise the PCMCIA cd rom I have.

Then I found instLux which installs a mini Grub onto your windows partition which you boot into. There are 4 versions of instLux, two for Ubuntu and two for OpenSuse. Each distro has a Net install and a CD ROM install version. I tried the CD ROM version first but it couldn’t find the CD rom either.

I booted back into windows and installed the Ubuntu Net install version of instLux. At first attempt, it fried my hard disk after stalling at 6% of install. A quick Win XP reinstall, reboot and retry was successful. I now have Ubuntu 6.06 installed with a very quick gnome theme with all icons turned off. Epiphany is super quick and will be my browser of choice on this machine (I haven’t installed Galeon yet though and Dillo is just minging). I did try to upgrade to Edgy Eft but it failed and after the hassles with the upgrade on my iBook (X wouldn’t start untill I managed to install the ATI drivers again), I’m not going to try again.  It’s a joy to use the machine again.

I’ve had a few freezes and hard reboots but it’s a hell of a lot faster than clunky win XP.

Server tears

Well, I received my server today. Quite surprisingly the packaging was a bit poor, with only bubble wrap wrapped around it. The RAID controller and PCI adaptor were loose inside. After some fretting I eventually got it running and booting into the installed Mandriva. I then started to install Ubuntu which would but install due to an apic problem.

4294669.209000] ..MP-BIOS bug: 8254 timer not connected to IO-APIC

I managed to disable this on boot (with help) to install which all went fine, then on reboot, after disabling apic again, there was a new error.

isapnp: No Plug & Play device found

And after disabling PnP (Plug and Play) in the Bios and rebooting I get yet another error –
BUG: soft lockup detected on CPU#0!

Which I cannot get around but a thread on Launchpad suggests trying Edgy Eft Knot-3 which is downloading at the moment, so I’ll give it a try in the morning.


Edgy Eft was superb and installed first time (after I removed the faulty RAID controller). All is good, loud but good.

Investing in a server

1u serverI’m not big into hardware and only really know what I need to. I’m not a gamer and have no need for any fancy graphics cards. I do however spend hours trawling ebay for servers. I am dying to buy one and I think the time has come. I had been looking at the Sun Cobalt RAQs as they are slick but it ties me to RAQ software or installing Strongbolt or similar. I have therefore changed my mind and have decided to go for a decent spec 1u server that has vga out and I can install Ubuntu Server. I reckon for under £300 I can get a dual PIII with over a gig of RAM and a couple of SCSI drives (RAID).

RAQ serverI can justify the cost of this as I already pay about $150 a year to dreamhost so after a couple of years it will have paid for itself. Karova will be getting some major server space soon and I hope to sneak the 1u server in there. If that doesn’t work out, I’ll have a awesome dev server I can screw into the bottom of my desk.

I’m aiming to have one by the end of the month so if you have any tips or pointers for purchasing a server, let me know in the comments.