Since installing Oracle XE (stands for eXpress Edition, basically a free edition) on Ubuntu 10.04 Lucid Lynx can be a little hell(read you can spend several hours banging your head against the wall of your choice), I’m writing this quick guide for reference. Bonus for Ruby enthusiasts: we will also install ruby-oci8. Let’s start.

Update the system

It’s a good habit to update the system before installing anything:

$ sudo aptitude update
$ sudo aptitude safe-upgrade

Install Oracle XE

First install two needed libs:

$ sudo aptitude install libaio1 libaio-dev bc

To install Oracle XE you need to add a new repository. Add this line at the end of /etc/apt/sources.list

deb unstable main non-free

Now, update the system:

$ sudo aptitude update

If you have an error saying that there is a problem with the repository key, do the following instead:

$ wget  -O- | sudo apt-key add -
$ sudo aptitude update

Now, install Oracle XE:

$ sudo aptitude install oracle-xe-universal oracle-xe-client

Configuring Oracle XE

As easy as

$ /etc/init.d/oracle-xe configure

it will ask a password for users SYS and SYSTEM

You can now verify that Oracle XE it’s up and running, browsing:


Bonus: installing ruby-oci8

Before anything, you have to set up some environment variables. At the end of your ~/.bashrc file, append:

export PATH=$PATH:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin

Restart your terminal.

You’re good to go:

$ sudo gem install ruby-oci8

If an error occurs about Oracle initialization, there is a good chance that your environment variables are missing. Retry the step above and RESTART your shell.

You can try if the gem is correctly installed using irb:

require 'rubygems'
require 'oci8'
tnsnames = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = = 1521)) (CONNECT_DATA = (SID = XE)))'
conn ='SYS', 'sys_pwd', tnsnames)
cursor = conn.exec('SELECT sysdate FROM dual')
while r = cursor.fetch()
puts r.join(',')

The code above should not throw any error.

That’s it!

Good job! You deserve any beverage of your choice.

Note: This quick install is for local installations useful for developpers. If you want to use it on production systems, it’s your call not mine.