Introduction

Drupal is a free, open source and web based content management system that can be used to build different types of websites. It is written in PHP and uses MariaDB to store their data. It is simple, easy to use and most popular content management system around the world. Drupal provides a rich set of features including, easy content authoring, reliable performance, stability, excellent security and much more.

In this tutorial, we will learn how to install Drupal CMS on Ubuntu 18.04 server.

Prerequisites

To follow this guide, you'll need a fresh installed Ubuntu 18.04 server, a regular, non-root user with sudo permission, enable a basic firewall to block non-essential ports, 2GB of memory and a processor with 2 cores and a valid domain name is pointed to your server IP address.

When you have an account available, log in as your non-root user to begin.

Step 1 - Install Apache, MariaDB and PHP

First, you will need to install Apache web server, MariaDB database server, PHP and other PHP modules to your system. You can install all of them by just running the following command:

$

sudo apt-get install apache2 mariadb-server php7.2 php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-intl php7.2-mysql php7.2-cli php7.2-tidy php7.2-recode php7.2-zip php7.2-curl libapache2-mod-php7.2 unzip curl git wget

Once installed, open php.ini file and tweak some settings:

$

sudo nano /etc/php/7.2/apache2/php.ini

Make the following changes:

/etc/php/7.2/apache2/php.ini

memory_limit = 256M upload_max_filesize = 100M max_execution_time = 30 max_input_vars = 1500 date.timezone = Asia/Kolkata

Save and close the file. Then, start Apache and MariaDB service and enable them to start after system reboot with the following command:

$$$$

sudo systemctl start apache2 sudo systemctl enable apache2 sudo systemctl start mariadb sudo systemctl enable mariadb

Step 2 - Configure Database

By default, MariaDB is not secured. So you will need to secure it first. You can secure it with the following command:

$

sudo mysql_secure_installation

Answer all the questions as shown below:

        

Enter current password for root (enter for none): Just press the Enter Set root password? [Y/n]: Y New password: Enter password Re-enter new password: Repeat password Remove anonymous users? [Y/n]: Y Disallow root login remotely? [Y/n]: Y Remove test database and access to it? [Y/n]: Y Reload privilege tables now? [Y/n]: Y

Once MariaDB is secured, log in to MariaDB shell with the following command:

$

sudo mysql -u root -p

Enter your root password when asked, then create a database and user for Drupal with the following command:

MariaDB > MariaDB >

CREATE DATABASE drupal; CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'password';

Next, grant all the privileges to the Drupal database with the following command:

MariaDB >

GRANT ALL ON drupal.* TO 'drupaluser'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

Next, flush the privileges and exit from the MariaDB shell with the following command:

MariaDB > MariaDB >

FLUSH PRIVILEGES; EXIT;

Step 3 - Install Drupal

First, download the latest version of Drupal from their official websites with the following command:

wget https://ftp.drupal.org/files/projects/drupal-8.7.5.zip

Once the download is completed, unzip the downloaded file with the following command:

unzip drupal-8.7.5.zip

Next, move the extracted directory to the Apache root directory and give proper permissions:

sudo mv drupal-8.7.5 /var/www/html/drupal
sudo chown -R www-data:www-data /var/www/html/drupal

Step 4 - Configure Apache for Drupal

Next, create an Apache virtual host file for Drupal with the following command:

sudo nano /etc/apache2/sites-available/drupal.conf

Add the following lines:

/etc/apache2/sites-available/drupal.conf

<VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html/drupal/ ServerName example.com

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

 <Directory /var/www/html/drupal/>
        Options FollowSymlinks
        AllowOverride All
        Require all granted
 </Directory>

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

Save and close the file when you are finished. Then, enable the required Apache modules with the following command:

$$$$

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

Next, enable Apache virtual host and restart Apache service to apply all the configuration changes:

$$

sudo a2ensite drupal.conf sudo systemctl restart apache2

Step 5 - Access Drupal

Now, open your web browser and navigate to URL http://example.com. You will be redirected to the following page: drupal-language-selection

Choose the language and click on the Save and continue button. You should see the following page: drupal-installation-profile Select an installation profile and click on the Save and continue button. You should see the following page: drupal-database-details

Provide your database details and click on the Save and continue button. You should see the following page: drupal-site-info drupal-admin-user-info Provide your site information, admin username, password and click on the Save and continue button. Once the installation has been completed, you should see the following page: drupal-dashboard

Congratulations! you have successfully installed Drupal on Ubuntu 18.04 server. You can now create your own site easily with Drupal.

Read more about: Ubuntu