How to Deploy Ruby On Rails Applications To Cloud VPS Servers

If you’ve outgrown Heroku’s “free” tier, it’s likely that you’ll want to examine the various ways you’re able to create a private VPS to run any Rails apps you may have.

In order to do this, you should really be looking at the various “cloud” hosting providers (such as Digital Water, Linode, etc) who have now begun to offer inexpensive VPS hosting onto which you’re able Free vps to deploy custom web based applications.

Since Rails is one of the cornerstones of modern web development, it’s important to consider how to set up a private server to run it. That it is quite easy.

99% Software…

The most important thing to remember with this is that to set up an HTTP (“web”) server, an individual require SOFTWARE to get it working.

The “web” works off the back of TCP/IP (the underlying “protocol” for the “Internet”) – which basically says that if you know the “public” IP address of a computer system, TCP/IP gives you the ability to attempt to “connect” to it.

Each time you “ping” a system, or perform any type of “handshaking”, it’s done through TCP/IP. This works in both a LAN (Local Area Network) and WAN (Wide Area Network) capacity, providing users with the ability to “connect” to other devices that are “connected” to the Internet.

The problem with TCP/IP is that whilst every system that’s “online” can be “pinged”, it cannot be accessed. TCP/IP uses “ports” which basically allow for particular data to be transferred in certain ways – firewall software (which is now built into most operating systems) block access to most ports, to prevent hacking.

The part where HTTP (Hyper Text Transfer Protocol) plays here is that it allows for a “public” set of on the internet – delivered through port 80 (or 443 if using SSL). ANY “HTTP” made it possible for computer system essentially “opens” a certain folder to the Internet, making it accessible via port 80 of the TCP/IP protocol. This is finished with “HTTP” (“Web”) server software.

To run a “web server”, you basically have to have a computer that’s powering the “Internet”, has a freely accessible IP address and is able to accept incoming asks for via the HTTP protocol on either port 80 or 443.

This is the start of how you set up a custom VPS server…

Servers Are a Dime-A-Dozen

Thus, anyone with an Internet connection, computer and HTTP server software (NGinx/Apache) can setup a web server.

You don’t even have to have a website – just use your public IP. Websites are given by ICANN as a way to make it better to access web servers – what most don’t know is that a “domain” name simply passages a request to particular IP address. It’s still incumbent on the domain owner & website developer to make that IP accessible to “web” traffic (port 80/443).

The point is that what you pay for “hosting” is really the infrastructure required to keep a server running & in business. “Shared” hosting is essentially the ability to buy a “user account” on a HUGE server (used by 1, 000’s of websites), whereby the “hosting company” will pay those electricity, maintenance and support to ensure maximum uptime.

The problem for most people is that whilst “shared” hosting is a great way to get a simple “WordPress” web page, if you want anything more exotic, you’re at a loss. Specifically, Rails and the likes of NodeJS or other “new” technologies (which require deeper OS integration for their dependencies).

The answer to this (for now) is to set up your own VPS servers. These allow you maximum control over the way the server works, and also gives you direct access to the underlying computer itself (which means you’re able to add as many dependencies as you want).

To do this, however, takes some setting up. This is done by firstly understanding the core settings / components required to get the server running & online. The following steps will explain how to do this.

Setting up a Server

VPS Running Ubuntu
The first step is to get a VPS instance. As mentioned, the best providers of these are the new “cloud” systems such as Vultr, DigitalOcean, AWS, etc. Don’t worry about paying huge money for this – $5/mo is perfect first. You also need to use an computer itself which is widely supported and not going to add unnecessary expense. Use Linux. You’re never going to look at the server after you’ve arrange it, so a costly Windows driver’s license won’t matter anyway. Ubuntu is currently the most popular Linux variant. Whilst you can use others, we just recommend Ubuntu for the sake of compatibility.

Install NGinx/Apache
Next, you need to install the web server software. This is just what will open port 80 (or 443) to the world, and also people to connection to the server with their web browser. It must be noted that you’ll also need to install the “application server” with the web server, which typically comes bundled jointly package. Both NGinx & Apache have their respective methods of achieving this, which are available on their websites.

Install Ruby & RubyGems
After you have installed the web server, you need to get Ruby/RubyGems installed. Whilst there are a number of ways to do this, the underlying basis is to build Ruby from source (which requires the build tools) and to install RubyGems on top of it.

Get GIT Set up
The way you get a Rails application onto the server is with GIT. To get this set up, you need to first download the GIT application (which is done through apt-get), and then add a custom (“bare”) GIT repository on the server. You then need to set up your local repository to handle the GIT remote repo, which will allow you to push to it.

Push The Instance & Get Any Extras Set up
After that, you need to ensure that you are able to push the instance to the server via GIT, and then add any extras (such as a database etc). Obviously, how you do this will be dependent on the “stack” setup that you have.
Ultimately, the process is actually quite mundane, and exactly the same as the myriad of “hosting” providers out there.

Leave a Reply

Your email address will not be published. Required fields are marked *