Installing PostgreSQL 10 and pgAdmin4 on Centos 7

Installing PostgreSQL 10 and pgAdmin4 on Centos 7

PostgreSQL is a free object-relational database management system (DBMS). PostgreSQL is based on Postgres, a non-profit database developed as an open-source project at the University of California, Berkeley.

Installing PostgreSQL 10

Add a repository and install PostgreSQL server and client

[[email protected]]# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-1.noarch.rpm
[[email protected]]# yum install postgresql10-server postgresql10

PostgreSQL directory: / var / lib / pgsql / 10 / data /

Initializing the base

[[email protected]]# /usr/pgsql-10/bin/postgresql-10-setup initdb

We start the service, add it to startup and check the status

[[email protected]]# systemctl start postgresql-10
[[email protected]]# systemctl enable postgresql-10
[[email protected]]# systemctl status postgresql-10

Let’s check PostgreSQL and set a password for the postgres user

[[email protected]]# su - postgres
$ psql

psql (10.0)
Type "help" for help.
postgres=# password postgres
Enter new password:
Enter it again:

Installing the pgAdmin 4 web client

Install software from PostgreSQL repository

[[email protected]]# yum install pgadmin4

During installation, due to dependencies, the following two packages pgadmin4-web and httpd web server will also be installed.

Renaming the config for the pgAdmin web interface

[[email protected]]# mv /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf

We bring the file to the form

[[email protected]]# nano /etc/httpd/conf.d/pgadmin4.conf
<VirtualHost *:80>
LoadModule wsgi_module modules/mod_wsgi.so
WSGIDaemonProcess pgadmin processes=1 threads=25
WSGIScriptAlias /pgadmin4 /usr/lib/python2.7/site-packages/pgadmin4-web/pgAdmin4.wsgi

<Directory /usr/lib/python2.7/site-packages/pgadmin4-web/>
        WSGIProcessGroup pgadmin
        WSGIApplicationGroup %{GLOBAL}
        <IfModule mod_authz_core.c>
                # Apache 2.4
                Require all granted
        </IfModule>
        <IfModule !mod_authz_core.c>
                # Apache 2.2
                Order Deny,Allow
                Deny from All
                Allow from 127.0.0.1
                Allow from ::1
        </IfModule>
</Directory>
</VirtualHost>

Next, we will create directories for lib and logs for pgAdmin4, and change their owner

[[email protected]]# mkdir -p /var/lib/pgadmin4/
[[email protected]]# mkdir -p /var/log/pgadmin4/
[[email protected]]# chown -R apache:apache /var/lib/pgadmin4
[[email protected]]# chown -R apache:apache /var/log/pgadmin4

Let’s edit the config file config_distro.py, adding the lines

[[email protected]]# nano /usr/lib/python2.7/site-packages/pgadmin4-web/config_distro.py

LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'

Let’s create a user account with which we will authenticate in the web interface.

[[email protected]]# python /usr/lib/python2.7/site-packages/pgadmin4-web/setup.py
NOTE: Configuration authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user account:

Email address:
Password:
Retype password:
pgAdmin 4 - Application Initialisation
======================================

Now you can type in the browser http: //% ip-address% / pgadmin4 to get into the web interface

Sidebar