This article is primarily for those hosting a VPS with Knownhost and using a CentOS/cPanel combination. However, if the server was set up correctly, this tutorial should work with any CentOS/cPanel server.
Where to start?
To begin, you must have atleast minimal experience with the command line interface. Users should have SSH access and know how to use it. If you have heard of Putty before, then you are probably good to go. We will be installing ruby manually, installing rails through gem and installing sqlite3 manually, please find out before hand that you absolutely need the newest version of ruby and rails before you update this. Managing ruby and gems is far easier if done through the gui cPanel interface. However, at the time of writing this they only allow upgrades to 1.8.7 and I needed 1.9.2 so here we go!
Installing Ruby 1.9.2:
Before we can do anything we need the newest version of ruby.
- Log into your command prompt and check the version and which ruby you are using:
ruby --version which ruby
- Most likely, your ruby version should be located at: /usr/bin or /usr/local/bin, now you must decide where to download your installation – I chose /var/tmp – change to that directory:
- Now grab the latest version of ruby (this may be out of date by the time you read it so look here for the latest version, simply copy the url of the download link on this page):
- Now that we have a fresh copy on our server, extract the zipped file (I downloaded a tar.gz file so extract with tar -zxf):
tar -zxf ruby-1.9.2-p180.tar.gz
- Change into the newly created directory after your done extracting:
- Configure the Makefile:
- Build the executable:
- Install the program:
- Check which path we are using for ruby:
- Check to see which version of ruby we are using:
If everything went smoothly you should have the newest version of ruby running on your system. It should most likely be run from /usr/local/bin and the version should match the filename you just downloaded.
Now Install Rails:
- This step is pretty easy, simply type in the command below and watch the magic happen:
gem install rails
If everything here worked correctly you should now have rails on your system! However, you probably won’t be able to run a rails server yet, if you enter the command below and receive an error about sqlite being out of date, then continue…
If you typed “gem install sqlite3-ruby” and it didn’t work, the you most likely need to compile the most recent version of sqlite3 manually. Here is where you can find the most up to date versions, I chose to install the tar.gz version.
- change to your /var/tmp directory again:
- Find the link for the most recent version of sqlite3 and copy it, then download it to your server:
- Unpack it:
tar -zxf sqlite-autoconf-3070500.tar.gz
- Change to the newly created install directory:
- Configure the Makefile:
- Make the application:
- Install the application:
If everything went well, you should have the newest version of sqlite3 installed on your server but you still need ruby to talk to it, so issue the command:
gem install sqlite3-ruby
Now Ruby should have a gem installed called sqlite3! This will allow you to run a ruby server.
Test Your Setup:
Now that you have installed everything you need to get your ruby server and rails application up and running you need to test to make sure it’s working.
- Navigate to your /home directory or wherever you are comfortable setting up a test blog:
- Run the following command:
rails new blog
- This has set up a very basic blogging application at (in my example) /home/blog, change to that directory:
- Run the rails server and navigate to your server to port 3000 to check it out! For instance, go to “http://mydomain.com:3000” or if you don’t have a domain for your server, just put in the IP address, so “http://22.214.171.124:3000”.
That should be it for getting your rails server up and running on a CentOS system running cPanel just like Knownhost’s setup. Now if you’d like to set up a database and get started building applications, I would advise checking out: