Install WordPress with PostgreSQL in 2 min

Shoaib Hassan
2 min readJan 23, 2019

--

In this article you will learn how to install WordPress along with the PostgreSQL which is very big issue i was facing in the last week.i try many method to install WordPress with PostgreSQL and at last i find one working way and i am sharing that method with you so you can install it easily.

This is what WordPress community quote about support of PostgreSQL.

Currently, the official WordPress distribution only supports the MySQL and Maria Db database engines. A number of people have requested support for other database engines, particularly the open-source PostgreSQL

I recommend not to use and waist your time on PG4WP which is very popular on the internet for their flaws and incomplete functionality that is incompatible with latest versions of the WordPress.

Instead of PG4WP we will use the Fork version of PG4WP special thanks to the kevin for making fork version which is compatible with any version of the WordPress so far.

In my case i am using Ubuntu with running server LAMP and if you didn’t install yet then go here

To install PostgreSQL on Ubuntu go here

Step 1: Create Database and User in your PostgreSQL

open your terminal in Linux and run below commands in sequence.

$ sudo su - postgres$ psql$ create database your_database;$ create user your_user with password ‘your_password’;$ grant all privileges on database your_database to your_user;$ \q 

Step 2: Download WordPress

# Point to your Server directory $ cd /var/www/html$ wget https://wordpress.org/latest.tar.gz# Then unzip the package using$ tar -xzvf latest.tar.gz# Remove the zip file$ rm -rf latest.tar.gz

Step 3: Download and configure the Fork version of WP4PG in your WordPress directory

$ cd wp-content // go to wp-content$ git clone https://github.com/kevinoid/postgresql-for-wordpress.git$ mv postgresql-for-wordpress/pg4wp Pg4wp$ rm -rf postgresql-for-wordpress$ cp Pg4wp/db.php db.php

Step 4: Configure the wp-config.php

/** The name of the database for WordPress */define('DB_NAME', 'your PostgreSQL database name will go here');
/** MySQL database username */define('DB_USER', 'your PostgreSQL database username will go here');/** MySQL database password */define('DB_PASSWORD', 'your PostgreSQL database password will go here');/** MySQL hostname */define('DB_HOST', 'localhost');

Step 5: Run the Install Script

Point a web browser to start the installation script.

If you placed the WordPress files in the root directory, you should visit: http://example.com/wp-admin/install.php

If you placed the WordPress files in a subdirectory called blog, for example, you should visit: http://example.com/blog/wp-admin/install.php

Good Luck! & Thanks for reading :) here is the link to github Repo

--

--

Shoaib Hassan

Full Stack Developer | JavaScript Enthusiast | Blogger