Configure PostgreSQL on Linux in Vesta control panel - Step by step process to perform it ?









To Setup PostgreSQL on Linux in Vesta Control Panel, we need a clean system "minimal install base".

PostgreSQL is a powerful, open source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Vesta related queries and tasks.

In this context, we shall look into how to set up PostgreSQL on Linux in Vesta.


How to Setup PostgreSQL on Linux in Vesta control panel ?

We can install the Vesta Control panel on an RHEL, CentOS, Debian, and Ubuntu server.


1. To Setup PostgreSQL on RHEL/CentOS

i. Install PostgreSQL packages:

# yum install postgresql postgresql-server postgresql-contrib phpPgAdmin

If we have to install PostgreSQL from the Remi repository, then do not forget to explicitly enable it:

# yum install –enablerepo=remi postgresql postgresql-server postgresql-contrib phpPgAdmin

ii. Then initialize the database cluster:

# service postgresql initdb

iii. Download HBA configuration:

# wget http://c.vestacp.com/0.9.8/rhel/pg_hba.conf -O /var/lib/pgsql/data/pg_hba.conf

iv. Eventually, tart the server:

# service postgresql start

v. Set oracle user password:

# su – postgres
# psql -c “ALTER USER postgres WITH PASSWORD ‘pgp4sw0rd'”
# exit

vi. Then enable pgsql database support in Vesta.

vii. Open /usr/local/vesta/conf/vesta.conf and set DB_SYSTEM to 'mysql,pgsql'

viii. Register pg instance in the control panel:

# v-add-database-host pgsql localhost postgres pgp4sw0rd

ix. Download phpPgAdmin configuration:

# wget http://c.vestacp.com/0.9.8/rhel/pga.conf -O /etc/phpPgAdmin/config.inc.php
# wget http://c.vestacp.com/0.9.8/rhel/httpd-pga.conf -O /etc/httpd/conf.d/phpPgAdmin.conf

x. Finally, restart the webserver:

# service httpd restart


2. To Setup PostgreSQL on Debian/Ubuntu

i. Initially, install PostgreSQL packages:

# apt-get install postgresql postgresql-contrib phppgadmin

ii. Download HBA configuration:

# wget http://c.vestacp.com/0.9.8/debian/pg_hba.conf -O /etc/postgresql/*/main/pg_hba.conf

iii. Then restart the server:

# service postgresql restart

iv. Set oracle user password:

# su – postgres
# psql -c “ALTER USER postgres WITH PASSWORD ‘pgp4sw0rd'”
# exit

v. Enable pgsql database support in Vesta.

vi. Open /usr/local/vesta/conf/vesta.conf and set DB_SYSTEM to ‘mysql,pgsql’

vii. Then register pg instance in the control panel:

# v-add-database-host pgsql localhost postgres pgp4sw0rd

viii. Download phpPgAdmin configuration:

# wget http://c.vestacp.com/0.9.8/debian/pga.conf -O /etc/phppgadmin/config.inc.php
# wget http://c.vestacp.com/0.9.8/debian/apache2-pga.conf -O /etc/apache2/conf.d/phppgadmin

ix. Eventually, restart the webserver:

# service apache2 restart


How to resolve Error encountered while configuring PostgreSQL on Linux in Vesta Control panel ?

Recently, we had a customer who came across the following error while trying to connect remote PostgreSQL:

psql: could not connect to server: Connection refused

In order to solve this, our Support Techs first ensure to start the PostgreSQL server on the remote server.

# /etc/init.d/postgresql start

If we get the error while it is running, we need to enable TCP/IP support.

By default, the PostgreSQL server only allows connections to the database from the local machine or localhost.


Step 1: Allow remote IP address to access PostgreSQL

We need to open the file, /var/lib/pgsql/data/pg_hba.conf. Login as Postgres user using su command:

$ su – postgres
$ vi /var/lib/pgsql/data/pg_hba.conf

Now append the following line.

To give access to the 192.168.1.0/24 network:

host all all 192.168.1.0 255.255.255.0 trust

Eventually, save and close the file.


Step 2: Allow communication over TCP/IP

We open PostgreSQL configuration file, /var/lib/pgsql/data/postgresql.conf

$ vi /var/lib/pgsql/data/postgresql.conf

Then bind and open TCP/IP port by setting tcpip_socket to true:

tcpip_socket = true

Finally, save and close the file.


Step 3: Restart PostgreSQL server

We restart the PostgreSQL server with the following command:

# /etc/init.d/postgresql restart

This will open default port 5432.


Step 4: Test the setup

We then use psql command from the client system as follows:

psql -h PostgreSQL-IP-ADDRESS -U USERNAME -d DATABASENAME


[Need urgent help with setting up PostgreSQL on Linux in Vesta Control panel? We'd be happy to assist. ]

Conclusion

This article covers how to install and setup PostgreSQL on Vesta Control panel running RHEL, CentOS, Debian, or Ubuntu server. PostgreSQL is an advanced version of SQL which provides support to different functions of SQL like foreign keys, subqueries, triggers, and different user-defined types and functions.


To set up PostgreSQL on a RHEL or CentOS:

1. Install PostgreSQL packages

yum install postgresql postgresql-server postgresql-contrib phpPgAdmin

* If you have remi installed then don't forget to explicitly enable it.

yum install --enablerepo=remi postgresql postgresql-server postgresql-contrib phpPgAdmin


2. Initialize database cluster

service postgresql initdb


3. Download hba configuration

wget http://c.vestacp.com/0.9.8/rhel/pg_hba.conf -O /var/lib/pgsql/data/pg_hba.conf


4.  Start the server

service postgresql start


5. Set oracle user password

su - postgres

psql -c "ALTER USER postgres WITH PASSWORD 'pgp4sw0rd'"

exit


6. Enable pgsql databases support in vesta.

open /usr/local/vesta/conf/vesta.conf and set DB_SYSTEM to 'mysql,pgsql'


7. Register pg instance in control panel

v-add-database-host pgsql localhost postgres pgp4sw0rd


8. Download phpPgAdmin configuration

wget http://c.vestacp.com/0.9.8/rhel/pga.conf -O /etc/phpPgAdmin/config.inc.php

wget http://c.vestacp.com/0.9.8/rhel/httpd-pga.conf -O /etc/httpd/conf.d/phpPgAdmin.conf


9. Restart web server

service httpd restart


To set up PostgreSQL on a Debian or Ubuntu:

1. Install PostgreSQL packages

apt-get install postgresql postgresql-contrib phppgadmin


2. Download hba configuration

wget http://c.vestacp.com/0.9.8/debian/pg_hba.conf -O /etc/postgresql/*/main/pg_hba.conf


3. Restart the server

service postgresql restart


4. Set oracle user password

su - postgres

psql -c "ALTER USER postgres WITH PASSWORD 'pgp4sw0rd'"

exit


5. Enable pgsql databases support in vesta.

open /usr/local/vesta/conf/vesta.conf and set DB_SYSTEM to 'mysql,pgsql'


6. Register pg instance in control panel

v-add-database-host pgsql localhost postgres pgp4sw0rd


7. Download phpPgAdmin configuration

wget http://c.vestacp.com/0.9.8/debian/pga.conf -O /etc/phppgadmin/config.inc.php

wget http://c.vestacp.com/0.9.8/debian/apache2-pga.conf -O /etc/apache2/conf.d/phppgadmin


8. Restart web server

service apache2 restart




Keep In Touch

We hope to hear from you.

Accept File Type: jpg,jpeg,png,txt,pdf,doc,docx