How To Install and Use phpPgAdmin on Ubuntu 24.04
Introduction
If you’re looking for a web-based tool to manage your PostgreSQL databases, phpPgAdmin is an excellent choice. It’s similar to phpMyAdmin but specifically designed for PostgreSQL. In this blog post, we’ll walk you through the steps to install and use phpPgAdmin on Ubuntu 24.04, ensuring you efficiently manage your databases with ease.
Prerequisites
Before we begin, ensure that you have the following:
- A server running Ubuntu 24.04.
- A user account with
sudo
privileges. - PostgreSQL installed on your server. If you haven’t installed it yet, you can do so using the command:
sudo apt update
sudo apt install postgresql postgresql-contrib
- Apache2 or any other web server installed and running. If you’re using Apache2, install it with:
sudo apt install apache2
- PHP installed on your server. Make sure to install the necessary PHP modules for better performance with PostgreSQL:
sudo apt install php php-pgsql php-xml php-mbstring php-curl
Step 1: Downloading phpPgAdmin
- Navigate to the official phpPgAdmin GitHub repository to download the latest version. The command below will download the archive to your server:
cd /var/www/html
sudo wget https://github.com/phppgadmin/phppgadmin/archive/refs/tags/release-7.13.0.tar.gz
Note: Replace the URL with the latest release link if needed.
- Extract the downloaded archive:
sudo tar -xvzf release-7.13.0.tar.gz
- Rename the extracted directory for easier access:
sudo mv phppgadmin-release-7.13.0 phppgadmin
- Remove the archived file:
sudo rm release-7.13.0.tar.gz
Step 2: Configure phpPgAdmin
- Navigate to the phpPgAdmin directory:
cd /var/www/html/phppgadmin
- Copy and rename the configuration file:
sudo cp config.inc.php-dist config.inc.php
- Open the configuration file using your preferred text editor, for example:
sudo nano config.inc.php
- Modify the following lines to improve security and adaptation for your environment:
- Change the default theme or layout by adjusting
$theme
value. - Set up authentication method by modifying
$conf['servers'][$i]['auth_type']
. For initial setup, you can use'config'
. In a production environment, it is recommended to use'http'
or implement proper authentication. - Ensure
$conf['servers'][$i]['host']
is set to'localhost'
if the database is hosted on the same server. After editing, save your changes and exit the text editor.
Step 3: Set Permissions
Ensure the web server can access the phpPgAdmin directory by adjusting permissions:
sudo chown -R www-data:www-data /var/www/html/phppgadmin
sudo chmod -R 755 /var/www/html/phppgadmin
Step 4: Configure Apache
Create a new configuration file for phpPgAdmin in Apache:
sudo nano /etc/apache2/sites-available/phppgadmin.conf
Add the following content:
Alias /phppgadmin /var/www/html/phppgadmin
<Directory /var/www/html/phppgadmin>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
Save the file and exit. Enable the newly created site configuration:
sudo a2ensite phppgadmin
Also, enable the required Apache modules:
sudo a2enmod rewrite
Finally, restart Apache to apply the changes:
sudo systemctl restart apache2
Step 5: Accessing phpPgAdmin
- Open your web browser and navigate to:
http://your_server_ip/phppgadmin
Replace your_server_ip
with your server’s actual IP address or domain.
- You should see the phpPgAdmin login page. Enter your PostgreSQL username and password to log in.
Conclusion
Congratulations! You have successfully installed and configured phpPgAdmin on your Ubuntu 24.04 server. Now you can administer your PostgreSQL databases through an intuitive web interface, making tasks like managing tables, executing queries, and monitoring your databases much more manageable.
As you work with phpPgAdmin, remember to enhance security by configuring user roles and limiting access accordingly. Check the official phpPgAdmin documentation for more advanced configurations and features.
If you have any questions or encounter any issues, feel free to leave a comment below. Happy database management!
Follow us at Greenhost.cloud for more insightful articles and tips on managing your cloud services!