Awesome Web Blog

GCP:2 Install Ruby and Postgres

| Comments

Hi All, Welcome to series 2, here are explaining about the ruby and Postgres installation to our GCP Server. If you know about that in linux 16.04 version, you can skip this tutorial. this is entirely based on the ubuntu 16.04 LTS machine and not much . I read the digital ocean, GoRails etc to publish this article and use the tehniques explained by them also.

Install Ruby

first need to connect to our GCP using pem file.

Install RVM

connect gpg keys

1
2
   sudo apt-get install gnupg2 -y
  gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3

Install curl

install curl if not installed

1
sudo apt-get install curl

Use curl for rvm script

Now use the curl to install the rvm script

1
\curl -sSL https://get.rvm.io -o rvm.sh

Install RVM

Now, the below command installs the latest version of the rvm and does all the depandancies.

1
cat rvm.sh | bash -s stable

Now, install the lates version of Ruby, using the below command

RVM use

Installing RVM to /home/username/.rvm/

Adding rvm PATH line to /home/username/.profile /home/username/.mkshrc /homeusername/.bashrc /home/username/.zshrc.

Adding rvm loading line to /home/username/.profile /home/username/.bash_profile /home/username/.zlogin.

Installation of RVM in /home/username/.rvm/ is almost complete:

  • To start using RVM you need to run source /home/username/.rvm/scripts/rvm in all your open shell windows, in rare cases you need to reopen all shell windows.

Install latest Ruby

    rvm install ruby --default

check the ruby Version

1
ruby -v

Install Postgres

execute the below commands one by one

1
2
3
4
5
sudo sh -c “echo ‘deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main’ > /etc/apt/sources.list.d/pgdg.list”
    wget –quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
    sudo apt-get update
    sudo apt-get install postgresql-common
    sudo apt-get install postgresql-9.5 libpq-dev

Roles in postgres

by default postgres create a root user called role here is “postgres”

to use that

1
sudo -i -u postgres

Create a New Role

We entered to the console, now, create a new Role.

1
createuser –interactive

now, the user is created, now to check that type

1
psql

when the console comes, then type

1
\du

To set Password for User

go to the psql by command

1
sudo -u postgres psql

type

1
\password user_name

this is the end of series, will post more in another series

all set. thanks guys, comment if any error or doubt happend.

install and setup unicorn GCP3

Comments