Are you looking forward to hosting your Ruby on Rails application on a shared hosting account? Look no further, I will elaborate the necessary steps to deploy BlueHost Ruby on Rails.
BlueHost has been offering shared hosting for a number of years with success. They’re currently standing out as one of the most popular web hosting providers.
In this article, I will show you – with the exact steps and screenshots – how to deploy Ruby on Rails on your BlueHost shared hosting account. The steps are easy and straight forward.
As a quick heads up, you may need to purchase a plan that offers multiple addon domains. You will also need to contact BlueHost support to enable SSH access.
Sign Up For BlueHost Web Hosting
If you’ve already bought web hosting from BlueHost, then you can skip this step and proceed. I will then show you how to host an addon domain on your BlueHost web hosting account.
If you’ve not yet bought web hosting, then let’s do it with a 57% exclusive discount (for a limited time). To grab your discount, You will need to use our promo link. This is an exclusive discount for our blog readers. I’m pretty positive you won’t want to miss it.
After visiting our promo link, Clik on “Get Started Now” to get your hosting account. BlueHost offers three different web hosting plans. The Plus plan is what I recommend for unlimited addon domains.
What’s Ruby on Rails?
Ruby is an advanced programming language. It’s mainly used for programming web applications and online frameworks. Most famous web applications nowadays are using RoR.
The language has been built on the agile development methodology; which allows small teams to build and extend features steadily and fast without repeating the same commands every once and while.
Why Ruby on Rails?
When we’ve mentioned that most famous applications use it, we really meant that. Ruby on Rails is the programming language of choice for many successful companies; Twitter, SoundCloud, Goodreads, and more.
While PHP is still being used a lot, RoR is more advanced and more suitable for larger projects. It is also a good choice if you want to focus on a small-scale high-quality application first and grow it over time.
Enabling Ruby on Rails at BlueHost
Ruby on Rails is a model-view-controller system that is used to create websites in Ruby driven by databases. The web application can be divided into three main parts: the view, the model and the controller.
I’ve simplified the steps below as much as I could. But please feel free to leave your comment below shall you’ve got any questions or inquiries.
Step 1 – SSH Access
BlueHost is enabling SSH Access by default to your account. You will just need to login to the cPanel and create an authentication key to verify the SSH connection.
The above-mentioned guide walks you through the whole process on how to connect to BlueHost using SSh. Instead, you may need to contact BlueHost and they’ll be able to set it up for you.
Step 2 – Addon Domain or Sub-Domain
Where you’ll be hosting your Ruby on Rails application? For me, I recommend to set ip up on a separate directory. I do prefer doing it on an addon domain. But you may also use a sub-domain.
You can easily setup an addon domain or a sub-domain via the BlueHost control panel. If you’ll proceed with an addon domain, make sure to point this new domain to BlueHost using the nameservers below:
- NS1.BLUEHOST.COM
- NS2.BLUEHOST.COM
And get to remember your app directory; /public_html/myapp.
Step 3 – Create Rails App
In BlueHost cPanel, head over to “programming” and click on “Ruby on Rails” icon. In there, proceed with creating a new app and call it “myapp“.
Set the application path “/railapps/myrubyapp“, select “Production” environment and click on “Create“. This will create your application right away.
Step 4 – Create a Symbolic Link
And here, you will need direct SSH access. As mentioned in step 1, you can easily get SSH activated on your BlueHost account. Once there, go directly to “Security” in your cPanel and click “SSH”.
You’re almost ready! The next step here is to point the “myapp” directory to the actual directory on your cPanel. Please proceed with running the following commands via SSH:
- cd ~/public_html
- rm -rf myrubyapp
- ln -s /home/<username>/railapps/myrubyapp/public myrubyapp
Step 5 – Verify Welcome Page
If you’ve completed the steps accurately, you should now be able to see the Ruby on Rails welcome page on the main domain. This is going to display the index.html page located in “/home/<username>/railapps/myrubyapp/Public_Directory“.
Step 6 – Customize .HTaccess File
Now, you will need to customize your HTaccess file. You can simply copy and paste the following code over to .htaccess file in your app directory. In these lines of code, we’re also enabling “FASTCGI for apache“.
- AddHandler fcgid-script .fcgi
- AddHandler cgi-script .cgi
- RewriteEngine On
- RewriteBase /
- RewriteRule ^$ index.html [QSA]
- RewriteRule ^([^.]+)$ $1.html [QSA]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
Step 7 – Database & Launch App
This step is quite easy and straight forward. You will just need to head over to “MySQL Databases” in your cPanel. And there, proceed with creating a database. Then, create a DB username. And you will need to connect both DB and username together.
Congratulations! At this point, you should be able to see your app on going directly to the main domain via the browser.
Ruby on Rails is a strong programming language for your app development project. VPS and Dedicated Servers are securing more resources for custom developments like this. But as well, servers will cost you more money.
A shared hosting environment will be very sufficient at the beginning for you. Ruby Gems system helps RoR with dependency management. The system will automatically update your RoR Gems to the latest version while maintaining a perfect performance.
It’s important to note that shared hosting is offering limited CPU and RAM usage. While you still can use RoR on shared hosting, an upgrade at a later point may be required for more recourses.
We always believe to start small and grow as you go. Since you’re just getting started with ruby on rails application, you can firstly use BlueHost shared hosting. As you go, you can scale up and upgrade based on the business flow and money resources.
It’s also very wise to educate yourself about the pros and cons of shared hosting. We’ve been using BlueHost for a couple of projects and things have been pretty smooth.
BlueHost Ruby on Rails
I’ve tried to make this article as simple and straight forward as possible. Following the above-mentioned steps will let you easily create and launch a Ruby on Rails app on BlueHost shared hosting account.
You should always monitor your application once it’s live. Deploying Rails is just the beginning. You must monitor your application and resources used when you release your production app.
This article is informative! I’ve spent some time to get it to work and I put this article together to make it easy for you to use Ruby on Rails on BlueHost as well. Let me know in the comments below if you’ve got any questions or inquiries.