How to install Drupal with PostgreSQL on a Debian 8 VPS

drupallogoIn this tutorial we will cover the steps needed to install the latest stable version of Drupal on your Debian 8 VPS along with PostgreSQL.

Drupal is very popular and easy to use open-source CMS (content management system ) written in PHP. It is distributed under the GNU General Public License and used for managing, publishing and organizing a website, regardless of whether it is a personal blog or a corporate website.

This install guide assumes that Apache and PHP are already installed and configured on your Debian 8 Linux VPS. If not, you can learn how to Install LAMP (Linux, Apache, MySQL, PHP) on Debian 9.

Please note that you don’t need to install MySQL because we will install and use PostgreSQL for the Drupal installation.

At the time of writing this tutorial, Drupal 7.39 is the latest stable version available and it requires:

– Web Server: Apache, Nginx or Hiawatha
– PHP: 5.2 or higher
– Database Server: MySQL – 5.0 or higher, PostgreSQL – 8.3 or higher, or SQLite

You can find more information about Drupal’s system requirements from their official documentation.

Login to your server via SSH

# ssh root@server_ip

Let’s reassure that we have the proper version of Debian installed on our server :

# lsb_release -a

Distributor ID: Debian
Description:    Debian GNU/Linux 8.2 (jessie)
Release:        8.2
Codename:       jessie

UPDATE THE SYSTEM

Make sure your server is fully up to date using:

# apt-get update && apt-get upgrade -y

Install Drush:

# apt-get install drush php-console-table

Debian Jessie installs the 5.10.0 version of Drush. If you like to install and use the latest release, enter the underneath commands:

# pear channel-discover pear.drush.org

# pear install drush/drush

Check if the update was successful:

# drush version

You should get the following output:

# Drush Version : 6.2.0

INSTALL DRUPAL

We will download the Drupal installation into the /var/www/html directory. Then unpack the archive and set the proper ownership so the files can be processed by Apache. The below commands do exactly that:

# cd /var/www/html/

# wget http://ftp.drupal.org/files/projects/drupal-7.39.zip

# unzip drupal-7.39.zip

# chown www-data: -R drupal-7.39

Rename the unpacked archive to your website name.

# mv drupal-7.39 your_domain

INSTALL POSTGRESQL

Now, you need to install PostgreSQL and create a database and user that you will need to finish the Drupal installation. Issue the following command:

# apt-get install postgresql postgresql-client php5-pgsql

Switch from root to the PostgreSQL user:

# su postgres

You can create a PostgreSQL user by executing:

# createuser drupaluser --pwprompt --encrypted

Enter your drupaluser password when prompted. Now, create a database and assign the user to it:

# createdb drupal --owner=drupaluser

Exit from the postgres user:

# exit

Last but not least, you need to create a new virtual host directive in Apache for your domain. You can create the file with your favorite text editor. For example we are using vim:

# vim /etc/apache2/sites-available/your_domain.conf

Replace your_domain with your actual domain name and paste the following into the file:

<VirtualHost *:80>

ServerAdmin webmaster@your_domain
ServerName your_domain

DocumentRoot /var/www/html/your_domain

<Directory /var/www/html/your_domain>
RewriteEngine on
RewriteBase /mysite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>

</VirtualHost>

Activate the rewrite module:

# a2enmod rewrite

Enable your new virtual host directive:

# a2ensite your_domain.conf

Restart Apache for the changes to take effect:

# /etc/init.d/apache2 restart

Next, enter your Drupal installation document root:

# cd /var/www/html/your_domain/

Change permissions of the CHANGELOG.txt to avoid security problems:

# chmod 600 CHANGELOG.txt

Now, open your favorite web browser and navigate to http://your_domain/install.php . You will be welcomed by the Drupal installation page like the one below:

drupal

Choose the Standard install. Click on Save and continue.

After you choose your language and the requirements are verified, the installation will take you to the ‘Set up database’ part. Here you need to check the Database Type to PostgreSQL and enter the database and user values that you configured previously. Also, under ‘ADVANCED OPTIONS’ you should set the database port to 5432. Use the below picture for reference:

drpos

Once you are finished, click on ‘Save and continue’. After the installation is completed, configure your site according to your needs. Congratulations, you have successfully installed Drupal with PostgreSQL on your Debian 8 VPS.


Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to do this installation for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

3 thoughts on “How to install Drupal with PostgreSQL on a Debian 8 VPS”

  1. If we have a personal server, how can we setup a vps in debian 8 ? Let’s suppose we want to install more than one website.

    Reply
    • This tutorial is tested on our virtual servers where you can host unlimited number of websites. Configuring a virtual server in Debian 8 is out of the scope of this tutorial. Thanks.

      Reply
  2. I have a drupal account. I knew that for installation drupal with PostgreSQL on a Debian is too much benefit. So I always wanted to do this. Thanks for sharing the actual process. Now I can do it properly.

    Reply

Leave a Comment