Need help?

Our experts have had an average response time of 13.52 minutes in October 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

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 *

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF