Tutorial

How To Install Drupal on a Virtual Server Running Ubuntu 12.04

Published on September 24, 2012
How To Install Drupal on a Virtual Server Running Ubuntu 12.04

Status: Deprecated

This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.

See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.

About Drupal

Drupal is a free and open source content management that uses a PHP and a backend database, such as MySQL. It was created in 2001 and is currently the 3rd most popular content management site online. It now has over 17,000 addons to customize its functionality.

Setup

The steps in this tutorial require the user to have root privileges on their virtual private server. You can see how to set that up in steps 3 and 4 of the Initial Server Setup

Before working with Drupal, you need to have LAMP installed on your virtual server. If you don't have the Linux, Apache, MySQL, PHP stack on your VPS, you can find the tutorial for setting it up here: How to Install LAMP on Ubuntu 12.04.

Once you have the user and required software, you can start installing Drupal!

Step One—Download Drupal

We can download Drupal straight from their website. Currently, the latest version is 7.15

wget  http://ftp.drupal.org/files/projects/drupal-7.15.tar.gz

This command will download the zipped Drupal package straight to your user's home directory on the virtual server. You can unzip it with the following command:

tar zxvf drupal-7.15.tar.gz 

Once the file is unzipped, move it your default web directory. For Apache users, this is most likely /var/www.

sudo mv drupal-7.15/* /var/www/

Step Two—Configure the Settings

After moving the Drupal files into the web directory, switch in to the Drupal directory:

cd /var/www/

There are a couple of steps we need to take here:

First, copy the default settings file and rename the duplicate. Do not rename the default file—you need both files for the Drupal installation.

 cp sites/default/default.settings.php sites/default/settings.php

Second, allow the installer to write to the configuration file by updating the permissions for the file and for the settings directory:

chmod a+w sites/default/settings.php
chmod a+w sites/default

Step Three—Create the Drupal Database and User

Now we need to switch gears for a moment and create a new MySQL directory for Drupal.

Go ahead and log into the MySQL Shell:

mysql -u root -p

Login using your MySQL root password. We then need to create a Drupal database, a user in that database, and give that user a new password. Keep in mind that all MySQL commands must end with semi-colon.

First, let's make the database (I'm calling mine Drupal for simplicity's sake—for a real server, however, this name is not very secure). Feel free to give it whatever name you choose:

CREATE DATABASE drupal;
Query OK, 1 row affected (0.00 sec)

Then we need to create the new user. You can replace the database, name, and password, with whatever you prefer:

CREATE USER druser@localhost;
Query OK, 0 rows affected (0.00 sec)

Set the password for your new user:

SET PASSWORD FOR druser@localhost= PASSWORD("password");
Query OK, 0 rows affected (0.00 sec)

Finish up by granting all privileges to the new user. Without this command, the Drupal installer will be able to harness the new mysql user to create the required tables:

GRANT ALL PRIVILEGES ON drupal.* TO druser@localhost IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

Then refresh MySQL:

FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Exit out of the MySQL shell:

exit

Drupal requires a specific php module. If it is not yet installed on your server, download php-gd:

sudo apt-get install php5-gd

Step Four—Access the Drupal Installer

Once you have placed the Drupal files in the correct location on your VPS, assigned the proper permissions, and set up the MySQL database and username, you can complete the remaining steps in your browser.

Access the Drupal installer by adding /drupal-7.15/ to your site's domain or IP address (eg. example.com/drupal-7.15/)

By Etel Sverdlov

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about us


About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
10 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

“Access the Drupal installer by adding /drupal-7.15/ to your site’s domain or IP address (eg. example.com/drupal-7.15/)”

So, this is what I get at the end of the manual http://is.gd/Gus3sr Any help?

As an alternative you can try use Wodby. It works like that: you connect your DigitalOcean account and Wodby creates CoreOS droplet and install docker infrastructure on it. Then you deploy your Drupal website in a click from the Wodby dashboard, every drupal website has integration with varnish and redis out of the box

Hi, I follow this to the letter and get to the last step and when I go to access the installer in my browser I get a “Not Found” error. I’m still using Ubuntu 12.04 so I assumed the directions should be the same. Any help?

I’m using the DigitalOcean Drupal image. So many issues. For some reason, images are being called from /sites/default/files/styles/medium/public/ when the latter three folders don’t even exist. None of the support pages on the web are less than 3 years old. I can’t find anywhere to correct this issue. Any suggestions?

I’m a noob and I’m not sure exactly what I did to get this working, but the Drupal installer kept insisting that I didn’t have a configuration file and it didn’t have the right permissions.

Based on http://www.howtoforge.com/how-to-install-drupal-on-ubuntu-14.04, I entered:

chown -R www-data.www-data /var/www/html/drupal-7.31 chmod -R 755 /var/www/html/drupal-7.31

And the installer worked.

For Ubuntu 14.04.1 LTS the default web root is no longer /var/www but rather /var/www/html.

Also, in order to enable clean urls you will need to edit the apache configuration files to allow overrides to come from the .htaccess file.

nano /etc/apache2/sites-available/000-default.conf

#add the following lines. The key item is AllowOverride All. <Directory /var/www/html> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>

I want many drupal and wordpress using serverpilot not cpanel. But website says

Your app “drupal” is set up. You should replace this index.php file with your own.

I put files in /var/www but it does not see them.

With some Drupal 7 installations, clean_urls are enabled by default. This will usually result in 404 errors as it conflicts with the default apache config on DigitalOcean LAMP droplets.

If you’re getting 404 errors, try disabling clean_urls to see if it fixes it. If you want to change the apache config to make clean_urls work, check this question. Also, refer to chas.snider’s comment above on the .htaccess and apache’s rewrite module.

Thanks to everyone at digitalocean and the wonderful community for all the help! You guys rock! :D

After configuring db you can access drupal site @ http://localhost/install.php

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
December 29, 2013

@Fábio: How did you install php5-gd? Are you running Apache or nginx?

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel