In this article, we will have explained the necessary steps to install and configure pgAdmin on CentOS 7. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
pgAdmin is the leading open-source feature-rich PostgreSQL administration and development platform that runs on Linux, Unix, MacOS, and Windows. pgAdmin can be used to manage PostgreSQL 9.2 and above.
Install pgAdmin on CentOS
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
sudo yum install epel-release sudo yum update
Step 2. Install PostgreSQL.
Go to the PostgreSQL repository download page, and add the PostgreSQL 9.4 repository:
rpm -Uvh https://download.postgresql.org/pub/repos/yum/testing/12/redhat/rhel-7-x86_64/pgdg-centos12-12-1.noarch.rpm
Now, Install postgresql with the following command:
yum update yum install postgresql94-server postgresql94-contrib
Initialize postgresql database using following command:
To start PostgreSQL service, run:
systemctl enable postgresql-9.4 systemctl start postgresql-9.4
Step 3. Install pgAdmin 4 on CentOS 7.
Once you have PostgreSQL installed on your system, run the following command to install pgAdmin 4:
yum install epel-release yum update
Now, Install phpPgAdmin, enter the following command:
yum install phpPgAdmin httpd
Step 4. Configure pgAdmin.
There are few minor configuration changes that need to be done to have pgAdmin4 running. First we will rename the sample conf file from pgadmin4.conf.sample to pgadmin4.conf:
cp /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf
Next, create a pgAdmin log and data directories:
mkdir /var/log/pgadmin4/ mkdir /var/lib/pgadmin4/
Create/Edit config_local.py file:
Add the following settings:
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'
Change permissions of directories so that Apache:
chown -R apache:apache /var/lib/pgadmin4/* chown -R apache:apache /var/log/pgadmin4/*
Run the following command to create a user account for the pgAdmin 4 web interface.
Finally steps, Restart the Apache web service:
systemctl restart httpd
Step 5. Configure Firewall.
If the Firewall is enabled, execute the following command to enable http service:
firewall-cmd --permanent --add-service=http firewall-cmd --reload
Step 6. Access pgAdmin 4.
Open a web browser and go to the following URL to access the pgAdmin 4 interface:
Congratulation, you have learned how to install and configure pgAdmin 4 on CentOS 7. If you have any questions, please leave a comment below.