logo
. . .

How to Install postgreSQL on Cyber Panel

Step 1: Access Your Server.
Log in to your server via SSH.

Step 2: Update Server Packages.
Before installing any new software, it’s a good practice to update your server packages:-
# [ sudo yum update ]

Step 3: Install PostgreSQL.
Install the PostgreSQL server and client packages. CyberPanel uses LiteSpeed, and PostgreSQL 12 is recommended. You can install it using the following command:-
# [ sudo yum install -y postgresql12-server postgresql12-contrib ]

Step 4: Initialize the Database.
Initialize the PostgreSQL database and start the service:-
# [ sudo /usr/pgsql-12/bin/postgresql-12-setup initdb ]
# [ sudo systemctl start postgresql-12 ]
# [ sudo systemctl enable postgresql-12 ]

Step 5: Create a Database and User.
Access the PostgreSQL command line and create a new database and user:-
# [ sudo -u postgres psql ]
Inside the PostgreSQL shell:-
CREATE DATABASE your_database_name;
CREATE USER your_username WITH PASSWORD ‘your_password’;
ALTER ROLE your_username SET client_encoding TO ‘utf8’;
ALTER ROLE your_username SET default_transaction_isolation TO ‘read committed’;
ALTER ROLE your_username SET timezone TO ‘UTC’;
GRANT ALL PRIVILEGES ON DATABASE your_database_name TO your_username;
\q

Step 6: Configure PostgreSQL.
Edit the PostgreSQL configuration file to allow connections from CyberPanel. Open the 'pg_hba.conf' file:-
# [ host all all your_server_ip/32 md5 ]
Save the file and exit.

Step 7: Restart PostgreSQL.
Restart the PostgreSQL service to apply the changes.
# [ sudo systemctl restart postgresql-12 ]

Step 8: Update CyberPanel Settings.
In the CyberPanel interface, go to the “Databases” section and add the PostgreSQL database details.