Linode Initial Server Setup to Deploy Web Apps

In this article, we will see how to setup a brand new server on Linode to deploy Web applications.

Step 1

Pick a OS and boot the Linode. I picked Ubuntu 18.04, because 18.10 has installation problems with nginx at this time.

Step 2

Set root password in Linode manager.

Step 3

SSH into the server as root:

ssh root@your-ip

If you want to reset root password:

passwd

Step 4

Add a user for deploying the Rails app:

adduser deploy

Provide deploy user password at the prompt.

Step 5

Give deploy user permissions

visudo

Add the line:

deploy   ALL=(ALL) ALL

after the line:

root ALL=(blah blah blah)

if you don't want to provide the password when you deploy:

deploy   ALL=NOPASSWD: ALL

This configuration is not needed if you set up password less login for deploy user as described in steps 6 and 7.

Step 6

On laptop:

cat ~/.ssh/id_rsa.pub

If the key is not already generated, generate it:

ssh-keygen -t rsa

Step 7

On your laptop, setup secure login into server without providing password:

ssh-copy-id deploy@your-ip

You will now be able to SSH into your Linode instance as deploy user without providing password:

ssh 'deploy@your-ip'

Step 8

Open ~/.ssh/config

Host blackbox
  Hostname 123.123.123.123
  User deploy

You can SSH into your server using the hostname for your server:

ssh blackbox

Step 9

On the server, as the deploy user, generate the ssh keys:

ssh-keygen -t rsa

Do not provide any password for the prompts.

Step 10

Copy the key:

cat /home/deploy/.ssh/id_rsa.pub

into bitbucket account. Now your server can pull code from your source code repository during deploy.

References

Rails Machine Wiki


Related Articles


Ace the Technical Interview

  • Easily find the gaps in your knowledge
  • Get customized lessons based on where you are
  • Take consistent action everyday
  • Builtin accountability to keep you on track
  • You will solve bigger problems over time
  • Get the job of your dreams

Take the 30 Day Coding Skills Challenge

Gain confidence to attend the interview

No spam ever. Unsubscribe anytime.