Before you choose to install your tools, you should try to install the base system. When talking about the base system, we mean the basic tools that make a server work. On your local machine (the development machine), you probably don’t need a lot. You just start your development server with
rails server and everything works. This is not true for the production machine. You need to setup a few things before you can actually proceed with the installation of tools that support rails.
You probably don’t think about this a lot because it’s always there, isn’t it? However, when deploying to production, the OS matters. You need something which is stable, is well known by a lot of folks - so that just in case you fall into a trouble, there are a number of people to help you solve an issue. Ubuntu fits the need and in this guide I am assuming that you would be using Ubuntu 18.04 LTS which is a pretty famous operating system. Thankfully, most cloud hosting providers ask you for nothing but a hostname and the hardware capacity. Select Ubuntu 18.04 LTS and start it.
Setting up SSH for passwordless access
For accessing your server, you would have to login to it. When you install the OS, you would probably receive the username and password so that you can log into your server remotely using SSH. The normal procedure (which most cloud service providers would set you up with) is to login using your username and password.
Given your server IP is
10.20.30.40 and the username is
ubuntu, you would normally type
ssh email@example.com and it would ask you for the password. You enter your password and you are logged in to the machine. However, you need to setup the server to let you in without asking the password. For this, you need to setup a SSH key-pair on your machine and add the public key on the remote server.
Setting up nginx on the server
We have already talked about the web server, and its importance. So it’s important that we install our web server right away. To install nginx, you need to type this at your terminal:
sudo apt install nginx
NOTE: any command prepended by
sudo might ask you for your password (depending on the configuration). Enter your user (not root user) password to proceed.
Once it gets installed, hitting the IP address (in our case
10.20.30.40) should show the nginx default page.