[Drupal] How to install Drupal 7 on Ubuntu 14.04 machine

| | 2 min read

Installing Drupal 7 on Ubuntu 14.04 machine is pretty simple. Here is a quick and easy way to setup a Drupal 7 fresh installation. All those new Drupal developers who would want to do a local Drupal setup, please read on.

Prerequisites: Development environment

  • PHP 5
  • MySQL
  • Apache

Step 1: Download Drupal 7

  • Download the newest stable version of Drupal 7 to your local machine (Download)
  • Decompress the file
  • Copy the files and folders to your ‘/home/user/public_html/’ directory

OR

Run these commands in your terminal:

$cd /home/user/public_html/
$drush dl drupal
$mv /home/user/public_html/drupal-7.28 /home/user/public_html/drupal7

Step 2: Create a new MySQL database

  • Create a new MySQL database and database user using phpmyadmin.

OR

Create database through your terminal:

$ mysql -u root -p
mysql> CREATE DATABASE db_drupal7;
mysql> GRANT ALL PRIVILEGES ON db_drupal7.* TO 'new-db-user'@'localhost' IDENTIFIED BY 'new-db-password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> quit

Step 3: Create a new virtual host directive in Apache.

Create a new Apache configuration file ‘drupal7.conf'

$vi /etc/apache2/sites-available/drupal7.conf
$ln -s /etc/apache2/sites-available/drupal7.conf /etc/apache2/sites-enabled/drupal7.conf

then, add the following to drupal7.conf file:

<VirtualHost *:80>
   ServerAdmin[email protected]
   DocumentRoot /home/user/public_html/drupal7
   ServerName drupal7.local
   ServerAlias www.drupal7.local
      <Directory /home/user/public_html/drupal7/>
         Options Indexes FollowSymLinks MultiViews
         Require all granted
      </Directory>
   ErrorLog /var/log/apache2/drupal7-local.com-error_log
   CustomLog /var/log/apache2/drupal7-local.com-access_log common
</VirtualHost>

Then, Add to hosts file

$sudo gedit /etc/hosts

Add,

127.0.0.1 drupal7.local

Step 4: Restart the Apache web server

$sudo service apache2 restart

Step 5: Set 'files' folder permission

$chmod a+w sites/default/files -R

Step 6: Install Drupal 7

Open your web browser. Now, type URL as http://drupal7.local and follow the Drupal instructions and you're done.