How to Install Drupal CMS on Ubuntu 17.04 | 17.10

Drupal is an opensource content management system that allows anyone to build amazing websites. It’s free and has a community of dedicated supporters building cool tools to enhance it.

This brief tutorial is going to show students and new users how to install Drupal on Ubuntu 17.04 | 17.10 with ease. Anyone can read and use this tutorial to build great websites using Drupal.

Like WordPress and Joomla, Drupal also is base on the LAMP stack. It requires a Linux machine, a webserver, database server and PHP scripts. Follow the easy steps below to get Drupal installed.

Step 1: Prepare Ubuntu

The first step getting Drupal installed is to prepare the Ubuntu machine. To do that, run the commands below to update all installed packages on the Ubuntu machine.

sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove

After updating the Ubuntu machine, you may have to reboot the system.

Step 2: Install Apache2

Now that Ubuntu is updated, run the commands below to install Apache2 webserver.

sudo apt-get install apache2

After installing Apache2, the commands below the can be used to stop, start and enable Apache2 web server.

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

Step 3: Install MySQL

After installing Apache2 webserver, run the  commands below to install MySQL database server.

sudo apt-get install mysql-server mysql-client

During the installation, you may get a prompt to create and confirm MySQL root password. Please create the root password as you’ll need it to manage the server. After installing MySQL, the commands below can be used to stop, start and enable MySQL.

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

Next, run the commands below to secure MySQL server.

sudo mysql_secure_installation

You’ll be prompted with series of prompts, follow the guide below to complete.

Enter password for user root: TYPE CURRENT ROOT PASSWORD

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.

Estimated strength of the password: 50 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...

 - Removing privileges on test database...

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

All done! 

After running the commands above, continue below to create a database and user for Drupal. To do that, logon to MySQL server by running the commands below.

mysql -u root -p

After logging in, run the sql statement below to create a database called drupal.


Next, run the statement below to create a database user called drupaluser and provide a password for the user.

CREATE USER drupaluser@localhost IDENTIFIED BY 'new_password_here';

Now that the database and user are created, give the user rights to manage the database. You can do that by running the commands below.

GRANT ALL ON drupal.* TO drupaluser@localhost;

After that, run the commands below to flush the permission to disk and apply changes made above


Exit MySQL

Step 4: Install PHP and other Modules

Finally, run the commands below to install PHP and other PHP related modules.

sudo apt-get install php libapache2-mod-php php-mysql php-xml php-mysql php-curl php-gd php-imagick php-imap php-mcrypt php-recode php-tidy php-xmlrpc

Step 5: Download Drupal Content

At this point, you should have the LAMP stack installed, MySQL database created with its user and all necessary PHP modules installed.

Your next task is to download Drupal files from online. At the time of writing, the latest version is 8.3.5.  Run the commands below to download Drupal 8.3.5.

cd /tmp && wget

Change the version number if newer ones are available. Next, run the command below to extract the downloaded file.

tar xzvf drupal*

Then, move Drupal content to Apache default root directory. The default root directory is at /var/www/html.

sudo mv drupal-8.3.5/* /var/www/html

Next, create a setting.php file by copying the default.settings.php file.

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

One thing you might want to do is remove Apache2 default html test file. To do that, run the commands below:

sudo rm /var/www/html/index.html

Next, change the file permission and ownership of the root directory.

sudo chmod -R 755 /var/www/html/*
sudo chown -R www-data:www-data /var/www/html/*

After that, enable Apache2 modules by running the command below:

sudo a2enmod rewrite
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime

Finally, open Apache2 default config file and make the highlighted changes below, then save the file.

sudo nano /etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>

     DocumentRoot /var/www/html/
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

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


Restart Apache2.

sudo systemctl restart apache2

After restart Apache2, open your web browser and browse to the server hostname or IP address and you should see Drupal configuration wizard as shown below.

On the next screen, select Standard installation and continue

Enter the database information and continue.

Wait for the installation to finish, then configure the site name, admin email, site maintenance account and password and finish the installation.

Congratulations! You have just installed Drupal CMS on Ubuntu.

You may also like the post below:

6 Replies to “How to Install Drupal CMS on Ubuntu 17.04 | 17.10”

  1. This went quite smoothly .. as a newly converted Windows user .. my only problem was the MySQL Strong password .. Finding a number of different attempts would fail – I did the Google search to find that it requires Uppercase, lowercase, number AND a special character. Thanks for the tutorial.

  2. When I started using the drupal I stuck up in an unknown error.
    The requested URL /admin/appearance was not found on this server.

  3. When I finished the install, and attempted to connect to the default page, I get this:


    * @file
    * The PHP page that serves all page requests on a Drupal installation.
    * All Drupal code is released under the GNU General Public License.
    * See COPYRIGHT.txt and LICENSE.txt files in the “core” directory.

    use Drupal\Core\DrupalKernel;
    use Symfony\Component\HttpFoundation\Request;

    $autoloader = require_once ‘autoload.php’;

    $kernel = new DrupalKernel(‘prod’, $autoloader);

    $request = Request::createFromGlobals();
    $response = $kernel->handle($request);

    $kernel->terminate($request, $response);

    I’m not sure what I did wrong, or how to fix this.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.