Introduction

PostgreSQL is a powerful, open-source relational database management system that is widely used for various applications. This guide will walk you through the steps to install PostgreSQL 15 on Rocky Linux 9, which can be effectively hosted on a Windows VPS UK for optimal performance and scalability.

Prerequisites

  • A Rocky Linux 9 server with root access
  • Basic knowledge of Linux commands
  • An active internet connection

Step 1: Update Your System

Start by updating your package index and upgrading any existing packages:

sudo dnf update -y

Step 2: Install the PostgreSQL Repository

To install PostgreSQL 15, you first need to enable the PostgreSQL repository. Run the following command:

sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Step 3: Install PostgreSQL 15

Now, install PostgreSQL 15 along with the PostgreSQL server:

sudo dnf install -y postgresql15 postgresql15-server

Step 4: Initialize the Database

After installing, you need to initialize the database. Run the following command:

sudo /usr/pgsql-15/bin/postgresql15-setup initdb

Step 5: Start and Enable PostgreSQL Service

Start the PostgreSQL service and enable it to start on boot:

sudo systemctl start postgresql-15
sudo systemctl enable postgresql-15

Step 6: Configure PostgreSQL

By default, PostgreSQL only allows local connections. To configure it for remote access, edit the configuration file:

sudo nano /var/lib/pgsql/15/data/postgresql.conf

Uncomment and change the following line to allow connections from any IP address:

listen_addresses = '*'

Next, edit the pg_hba.conf file to allow remote connections:

sudo nano /var/lib/pgsql/15/data/pg_hba.conf

Add the following line at the end of the file:

host    all             all             0.0.0.0/0               md5

Step 7: Restart PostgreSQL Service

After making changes, restart the PostgreSQL service:

sudo systemctl restart postgresql-15

Step 8: Verify PostgreSQL Installation

To verify that PostgreSQL is running, you can check its status:

sudo systemctl status postgresql-15

You can also connect to the PostgreSQL database using the following command:

sudo -u postgres psql

Step 9: Conclusion

You have successfully installed PostgreSQL 15 on Rocky Linux 9, providing you with a powerful database management system. This setup can greatly benefit from being hosted on a Windows VPS. For additional options, explore various VPS UK Windows solutions, including Windows Virtual Private Server Hosting and Windows VPS Hosting UK for optimal database performance.

© 2024 PostgreSQL Installation Tutorial. All rights reserved.

Hai trovato utile questa risposta? 0 Utenti hanno trovato utile questa risposta (0 Voti)