How to Install Drupal on Ubuntu VPS

Posted on in University

Drupal is probably one of the best open source CMS, especially since the latest framework update. The PHP-based CMS is now very stable and adaptable to various platforms, which makes it a great proposition for individual bloggers, corporate websites, and much more. However, many people do not know how to install Drupal on Ubuntu VPS. You can now easily install it using this fairly straightforward process.

Installing Drupal on Ubuntu VPS-Recovered

Note: Before actually installing Drupal, you need to have Apache, MySQL, and PHP configured on the server.

STEP 1: Creating MySQL Database

You will have to create and then configure your MySQL database and user details for Drupal installation. For the sake of security, create and deploy dedicated user and database. To create database and user, you will have to log in to MySQL console and enter the password where required:

mysql -u root –p

Now that you’re logged in, create the Drupal database using:

create database xy;

The xy is the name of the database. Follow this by creating the database user and password for the user. This will give Drupal access to the new database:

create user [email protected] IDENTIFIED BY what_password’;

We have named David as the user and what as the password but you can always change it. Once you have created the database and user, you will have to give full permission to the user by:


TABLES ON drupal.* TO [email protected];

Use this for the changes to take immediate effect:

flush privileges;

Now simply type exit to exit the MySQL database.

STEP 2: Installing PHP Modules

To install the necessary modules, use:

apt-get install php5-gd php5-curl libssh2-php

You should also look to implement a few tweaks as recommended by the Drupal Community by editing the PHP configuration file:

nano /etc/php5/apache2/php.ini

Set “expose_php” and “”allow_url_fopen”” directives as “Off” using:

. . .
expose_php = Off
. . .
allow_url_fopen = Off
. . .

Follow this by restarting Apache service:

service apache2 restart

STEP 3: Enabling Rewrite AND htaccess In Apache

By enabling the rewrite functionality, the Drupal site will be able to modify URLs for easy reading. While the mod_rewrite module is preinstalled in Apache, it is not enabled by default. Enable it using:

a2enmod rewrite

Restart your Apache for changes to take effect:

service apache2 restart

We’ll now setup virtual host configuration to allow .htaccess usage. .htaccess file is where the rewrite rules are by default. Do the edit in Apache default configuration file using:

nano /etc/apache2/apache2.conf

In “Directory” block, set the AllowOverride directive as “All”.

Your block should now look like:


STEP 4: Installing DRUPAL

Download the latest version of Drupal and choose the ‘copy link address’ option by right clicking the tar.gz link. Now go to the server SSH/console prompt to download, extract, and move the files from the link:

cd ~

1. wget
2. tar xzvf drupal*
3. mv -v drupal*/* /var/www/html/

After moving the files, change the current working directory to web root directory for customization:

cd /var/www/html/

You will also have to create new directory under sub-tree sites/default called files:

mkdir -p /var/www/html/sites/default/files

Now copy the default settings file onto the active configuration filename that Drupal uses:

cp /var/www/html/sites/default/default.settings.php /var/www/html/sites/default/settings.php

Now modify the file permission and group ownership of files:

chmod 664 /var/www/html/sites/default/settings.php

chown -R www-data:www-data /var/www/html/*

Your server is now non-configured so start the web-based installation script. To complete the installation, type:

http://server_ip_address/index.php  (the server_ip_address should be replaced with the actual IP)

Once you’re on the Drupal Installation Page, enter your MySQL info, save the changes, and there you have it. Your Drupal is now live on your Ubuntu VPS.

You may also like to read