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.
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.
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!
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/
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
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
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/)
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
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!
“PDOException: SQLSTATE[HY000] [2003] Can’t connect to MySQL server on ‘127.0.0.1’ (111) in lock_may_be_available() (line 167 of /var/www/includes/lock.inc).”
I’m using trial account with Ubuntu 12.04 x64. following your tutorials for LAMP stack on 12.04 and phpmyadmin. After install drupal the mysql breaks I need to restart apache2 and even after that when trying to access drupal’s db through phpmyadmin mysql breaks “#2002 Cannot log in to the MySQL server”. the drupal installation doesn’t seems to be completed becase I can’t access the admin pages (no such account, or email in the db)
After Rebooting the image , delete and add new drupal db, after the installation this is what I get : http://imgur.com/Zaju8
I ran through the 3 tutorials that you mentioned in your first comment on a fresh trial install and was unable to replicate this error.
However, I found that this is a common issue with drupal installations and is discussed in further detail on the drupal message board here: http://drupal.org/node/1014172
Drupal says to change permission back after install. Drupal.org suggests the following. chmod 640 settings.php chmod 755 …/default When I do this and refresh browser the installation script restarts from the beginning. Any ideas why this is happening. I’ve reinstalled drupal a couple times now. If I don’t change permission it seems to be ok, but it is recommended for security reasons. Thanks in advanced!
Prior to the modifications on the ownership of those files everything was working fine?
Yeah, seems fine. One time i did not change permision and was able to navigate and set up cron, etc…w/ no problem. I only update the permision because of drupals suggestion for security. all ive done on my droplet is DO initial server setup, set up virtual host, LAMP tutorial and Drupal turorial. I posted on Drupal.org too. I’ll share if i get an answer there.
Setting a directory to 755 shouldn’t have affected anything since its still readable by all users so the web server can navigate there and serve files, as for the settings.php file you would need to review that in regards to Drupal. Unfortunately most of my work is in Rails so I’m not familiar with Drupal myself.
But try to just revert the permissions one at a time, first try the …/default permissions resetting them back to the original and then for settings.php and then update according to the security doc one at a time and see which one is causing the break, then we’ll have more info to troubleshoot.
it was happening with setting.php I found… http://drupal.org/node/1858044 settings.php must be readable by the webserver user. so I followed… http://bridgecitystudio.com/tutorials/fixing-permissions-files-directory-drupal and set settings.php to chmod 755. The security popup on drupal is gone and no more crash to installer. Thanks!
… correction settings.php set to 644
Or get it done with just 3 commands - it will install complete BOA stack with Aegir control panel:
$ wget -q -U iCab http://files.aegir.cc/BOA.sh.txt $ bash BOA.sh.txt $ boa in-stable public server.fqdn your@email o1 mini