Installing Rails Server on Ubuntu 12.04 with RVM, Nginx, Passenger and Oracle support
We have a new product ready and it is a Ruby on Rails webshop bundled with an ERP software written on Oracle Forms 6i. I will not go into the details of this work, maybe later i will make some posts of the process but as it is very linked to current software(only authentication is done with Devise, every other data and processing is done internally on Oracle database) there is no sense for me to explain it deeper. Off to the installation.
Server installation and configuration
First we need a clean install of Ubuntu server 12.04, x86 or x64 version will work all the same, but be careful later on when you download the Oracle instant client. On the installation, fill all the relevant data needed, and for installed services, choose only the ssh server, as you won’t be needing anything more. Another reminder: this will only be the webserver, assuming that you have the Oracle database installed somewhere in network reach. After you login to your server for the first time, take your time to set up the ip address because it defaults to dhcp. Edit the /etc/network/interfaces file and fill your address, gateway and dns servers(this is a new thing, i think starting in 12.04 /etc/resolv.conf gets updated whenever you restart networking, so everything you write there will get overwritten)
After the config is saved, restart the networking and do a full update/upgrade of the server to get the latest packages installed:
After all is done, reboot your server.
Installing RVM and latest Ruby version
After your server is updated you can proceed with installing RVM and the latest stable Ruby(as i’m writing this, the latest version is 1.9.3p194 so i will be using this version) First we install RVM prerequisites:
And that will install RVM and make it available for all users that belong to the rvm group(hint: edit /etc/groups and add rvm after the desired username). After installing RVM and adding our user to the rvm group we are off to installing latest Ruby version
## Installing Passenger and Nginx web server After you have ruby and everything needed installer go and install passenger gem and nginx web server with it
The installation will set up the nginx.conf file for you and show you how you can enable a rails site on your server. But i will include a sample config later on. Just for convenience, symlink nginx conf folder that is in /opt/nginx/conf to /etc/nginx and download linode nginx startup/shutdown script
Installing Oracle instant client
To connect your Rails application to Oracle database, you will have to install Oracle client, either full or instant one. As installing full client requires alien and converting .rpm packages to .deb it’s a bit of a hassle. Also, it will consume more space on your drive, and all that is unnecessary, we are trying to keep it small here.
First you should download zip files from Oracle site depending what architecture you are running:
Oracle Instant Client 11.2 for linux: X86, X64
Download only instantclient-basic, instantclient-sqlplus and instantclient-sdk zip archives and unzip them all into the same instantclient_11_2
folder. Now as sudo move that folder so the path is /opt/oracle/instantclient_11_2
After that you only have to add two environment variables to be able to install ruby-oci8 gem, which is prerequisite for running Ruby applications on Oracle database. Add the following lines to /etc/enviroment
file
After you reboot you have to symlink the oracle library so it will function properly(i don’t know why they don’t do this themselves).
After that try and install ruby-oci8 gem.
If there are no errors, and there should not be if you followed the guide, you are set to deploy your application on the server you just installed. In the next post, i plan to write something about tips, tricks and caveats of developing Rails applications on Oracle database. Useful links to get and learn about all the stuff i have mentioned in the post: Ruby Version Manager(RVM): https://rvm.io Ruby: http://ruby-lang.org Oracle Instant Client 11.2 for linux: X86, X64 Passenger server: http://www.modrails.com/
Comments