Use PostgreSQL 10 with Ruby on Rails on CentOS 7, demand a configuration a bit different from usual, in this article we’ll see how to make it.

If you haven’t the PostgreSQL, you can to install it following this tutorial.

Install requirements

First of all, configure the CentOS to ignore the PostgreSQL existent at your repositories.

sudo sed -e '/exclude=postgresql\*/d' \
  -e '/^\[base\]$\|^\[updates\]$/a exclude=postgresql*' \
  -i /etc/yum.repos.d/CentOS-Base.repo

Now install the requirements.

sudo yum install -y https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
sudo yum install -y postgresql10-devel

Configure the Bundler

After install the requirements, add the gem pg in Gemfile of your project and configure on bundler the path to pg_config, otherwise the installation gem will fail.

bundle config build.pg --with-pg-config=/usr/pgsql-10/bin/pg_config

And finally to install the gem, at your project root path, run.

bundle install

Configure database.yml

Rather of to run your app, remember to configure your database.yml, with the needed parameters to use PostgreSQL.

Wrapping up

In this soon article we saw how to use the PostgreSQL 10 with Ruby on Rails on CentOS 7, what isn’t difficult task, but get away a bit from the usual.

See you!

Resources