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
- 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
- Then initialize the database cluster:
# service postgresql initdb
- Download HBA configuration:
# wget http://c.vestacp.com/0.9.8/rhel/pg_hba.conf -O /var/lib/pgsql/data/pg_hba.conf
- Eventually, tart the server:
# service postgresql start
- Set oracle user password:
# su – postgres # psql -c “ALTER USER postgres WITH PASSWORD ‘pgp4sw0rd'” # exit
- Then enable pgsql database support in Vesta.
- Open /usr/local/vesta/conf/vesta.conf and set DB_SYSTEM to ‘mysql,pgsql’
- Register pg instance in the control panel:
# v-add-database-host pgsql localhost postgres pgp4sw0rd
- 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
- Finally, restart the webserver:
# service httpd restart
Setup PostgreSQL on Debian/Ubuntu
- Initially, install PostgreSQL packages:
# apt-get install postgresql postgresql-contrib phppgadmin
- Download HBA configuration:
# wget http://c.vestacp.com/0.9.8/debian/pg_hba.conf -O /etc/postgresql/*/main/pg_hba.conf
- Then restart the server:
# service postgresql restart
- Set oracle user password:
# su – postgres # psql -c “ALTER USER postgres WITH PASSWORD ‘pgp4sw0rd'” # exit
- Enable pgsql database support in Vesta.
- Open /usr/local/vesta/conf/vesta.conf and set DB_SYSTEM to ‘mysql,pgsql’
- Then register pg instance in the control panel:
# v-add-database-host pgsql localhost postgres pgp4sw0rd
- 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
- 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.
0 Comments