Bobcares

Setup PostgreSQL on Linux in Vesta control panel

by | Apr 3, 2021

To Setup PostgreSQL on Linux in Vesta, we need a clean system “minimal install base”.

As part of our Server Management Services, we assist our customers with several Vesta queries.

Today, let us see how we can set up PostgreSQL on Linux in Vesta.

 

Setup PostgreSQL on Linux in Vesta control panel

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

Setup PostgreSQL on RHEL/CentOS

  1. 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
  2.  Then initialize the 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. Eventually, tart the server:
    # service postgresql start
  5. Set oracle user password:
    # su – postgres
    # psql -c “ALTER USER postgres WITH PASSWORD ‘pgp4sw0rd'”
    # exit
  6. Then enable pgsql database support in Vesta.
  7. Open /usr/local/vesta/conf/vesta.conf and set DB_SYSTEM to ‘mysql,pgsql’
  8. Register pg instance in the control panel:
    # v-add-database-host pgsql localhost postgres pgp4sw0rd
  9. 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
  10. Finally, restart the webserver:
    # service httpd restart

 

Setup PostgreSQL on Debian/Ubuntu

  1. Initially, 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. Then 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 database support in Vesta.
  6. Open /usr/local/vesta/conf/vesta.conf and set DB_SYSTEM to ‘mysql,pgsql’
  7. Then register pg instance in the control panel:
    # v-add-database-host pgsql localhost postgres pgp4sw0rd
  8. 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
  9. Eventually, restart the webserver:
    # service apache2 restart

 

Error while we Setup PostgreSQL on Linux in Vesta

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 help with any of the above? We’d be happy to assist]

 

Conclusion

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

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.