Objective
The objective is to install Drupal on Ubuntu 18.04 Bionic Beaver Linux
Operating System and Software Versions
- Operating System: – Ubuntu 18.04 Bionic Beaver
- Software: – Drupal 8.4.5 or higher
Requirements
Privileged access to your Ubuntu System as root or via sudo
command is required.
Difficulty
EASY
Conventions
- # – requires given linux commands to be executed with root privileges either directly as a root user or by use of
sudo
command - $ – requires given linux commands to be executed as a regular non-privileged user
Instructions
Prerequsites
Let’s start by installing prerequisites. For the Drupal installation we will need curl
and tasksel
command. The following linux command will install both:
$ sudo apt install -y curl tasksel
This guide will use Ubuntu LAMP stack ( Linux, Apache, MySQL, PHP) to run under the Drupal installation.
If you wish to run Drupal using Nginx webserver then follow our guide on How To Install Nginx, MariaDB, PHP (LEMP stack) on Ubuntu 18.04.
Next, install Ubuntu LAMP stack using tasksel
command and enable rewrite
mode:
$ sudo tasksel install lamp-server $ sudo a2enmod rewrite
Next, install additional PHP module Drupal requirements:
$ sudo apt install php-fdomdocument php-gd
We also need to enable “Clean URLS” for our Durpal installation. To do so edit /etc/apache2/sites-enabled/000-default.conf
Apache’s default site configuration file:
$ sudo nano /etc/apache2/sites-enabled/000-default.conf
Once ready, add the following code below DocumentRoot /var/www/html
line:
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
To apply the changes restart your Apache web server:
$ sudo systemctl restart apache2
We are now ready to download Drupal.
Download Drupal
At this stage we are ready to download and decompress the Drupal tarball into webserver’s root directory. Start by downloading the latest Drupal package and save it into your /tmp
directory using your web browser.
Alternatively, the bellow command is using curl
to download Drupal tarball version 8.4.5
:
$ curl --output /tmp/drupal.tar.gz https://ftp.drupal.org/files/projects/drupal-8.4.5.tar.gz
Next, install Drupal files into Webserver’s root directory /var/www/html
and change the file ownership to www-data
. Change your downloaded Drupal version number where appropriate:
$ sudo rm -fr /var/www/html $ sudo tar xf /tmp/drupal.tar.gz -C /var/www/ $ sudo mv /var/www/drupal-8.4.5/ /var/www/html $ sudo chown -R www-data.www-data /var/www/html
All set, we are now ready to configure database for the Drupal installation.
Configure Database
In this section we will create a new MySQL database Drupal
and assign a user access to it to a new user admin
with password pass
:
$ sudo mysqladmin create drupal $ sudo mysql -e "CREATE USER 'admin'@'%' IDENTIFIED BY 'pass';" $ sudo mysql -e "GRANT ALL PRIVILEGES ON drupal.* TO 'admin'@'%' WITH GRANT OPTION;"
For more configuration options regarding MySQL database installation visit page: Install MySQL on Ubuntu 18.04.
Install Drupal
We are now ready to install Drupal.
Given that your Drupal server can be resolved via drupal-ubuntu
host name, open up your browser and navigate to URL http://drupal-ubuntu
to access Drupal installation wizard:
To fix this issue we must edit the default Drupal configuration file /var/www/html/sites/default/settings.php
.
$ sudo nano /var/www/html/sites/default/settings.php
Once ready, append the following code to the end of the file while updating your drupal website hostname/domain.
For example, for hostname drupal-ubuntu
and domain linuxconfig.org
add the following code.:
$settings['trusted_host_patterns'] = array(
'^drupal-ubuntu
The above will add both drupal-ubuntu
and domain linuxconfig.org
as trusted hosts.
,
'^www\.linuxconfig\.org
The above will add both
drupal-ubuntu
and domain linuxconfig.org
as trusted hosts.
,
);
The above will add both drupal-ubuntu
and domain linuxconfig.org
as trusted hosts.