Would you like to learn how to do a Drupal installation on Ubuntu Linux? In this tutorial, we are going to show you how to install, configure and access the Drupal CMS on a computer running Ubuntu Linux.

• Ubuntu Linux Version: 18.04

Hardware List:

The following section presents the list of equipment used to create this Drupal tutorial.

Every piece of hardware listed above can be found at Amazon website.

Drupal Related Tutorial:

On this page, we offer quick access to a list of tutorials related to Drupal installation.

Tutorial – NTP on Ubuntu Linux

First, we are going to configure the system to use the correct date and time using NTP.

On the Linux console, use the following commands to set the correct timezone.

# dpkg-reconfigure tzdata

Install the Ntpdate package and set the correct date and time immediately.

# apt-get update
# apt-get install ntpdate
# ntpdate pool.ntp.br

The Ntpdate command was used to set the correct date and time using the server: pool.ntp.br

Let’s install the NTP service.

# apt-get install ntp

NTP is the service that will keep our server updated.

Use the command date to check the date and time configured on your Ubuntu Linux.

# date

If the system shown the correct date and time, this means that you followed all the steps correctly.

Tutorial – MySQL Installation on Ubuntu Linux

Now, we can proceed to the installation of the database service.

On the Linux console, use the following commands to install the required packages.

# apt-get update
# apt-get install mysql-server mysql-client

After finishing the installation, use the following command to access the MySQL database server.

# mysql -u root -p

Use the following SQL command to create a database named Drupal.

CREATE DATABASE drupal CHARACTER SET UTF8 COLLATE UTF8_BIN;

Use the following SQL command to create a database user named drupal.

CREATE USER ‘drupal’@’%’ IDENTIFIED BY ‘kamisama123’;

Give the sql user named drupal permission over the database named drupal.

GRANT ALL PRIVILEGES ON drupal.* TO ‘drupal’@’%’;
quit;

Tutorial – Installing Apache on Linux

Now, we need to install the Apache web server and all the required software.

On the Linux console, use the following commands to install the required packages.

# apt-get install apache2 php7.2 php7.2-mysql libapache2-mod-php7.2
# apt-get install php7.2-gd php7.2-mbstring php7.2-xml

Enable the Apache mod_rewrite and edit the apache2.conf file.

# a2enmod rewrite
# vi /etc/apache2/apache2.conf

Here is the original file, before our configuration.

DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch “^\.ht”>
Require all denied
</FilesMatch>
LogFormat “%v:%p %h %l %u %t \”%r\” %>s %O \”%{Referer}i\” \”%{User-Agent}i\”” vhost_combined
LogFormat “%h %l %u %t \”%r\” %>s %O \”%{Referer}i\” \”%{User-Agent}i\”” combined
LogFormat “%h %l %u %t \”%r\” %>s %O” common
LogFormat “%{Referer}i -> %U” referer
LogFormat “%{User-agent}i” agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

At the end of the file, add the following lines.

<Directory /var/www/html>
AllowOverride All
</Directory>

Here is the new file with our configuration.

DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch “^\.ht”>
Require all denied
</FilesMatch>
LogFormat “%v:%p %h %l %u %t \”%r\” %>s %O \”%{Referer}i\” \”%{User-Agent}i\”” vhost_combined
LogFormat “%h %l %u %t \”%r\” %>s %O \”%{Referer}i\” \”%{User-Agent}i\”” combined
LogFormat “%h %l %u %t \”%r\” %>s %O” common
LogFormat “%{Referer}i -> %U” referer
LogFormat “%{User-agent}i” agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
<Directory /var/www/html>
AllowOverride All
</Directory>

Now, you should find the location of the php.ini file on your system.

After finding, you need to edit the php.ini file.

# updatedb
# locate php.ini
# vi /etc/php/7.2/apache2/php.ini

Keep in mind that your PHP version and the location of the file may not be the same of mine.

Here is the original file, before our configuration.

file_uploads = On
max_execution_time = 30
memory_limit = 128M
post_max_size = 8M
max_input_time = 60
; max_input_vars = 1000

Here is the new file with our configuration.

file_uploads = On
max_execution_time = 300
memory_limit = 256M
post_max_size = 32M
max_input_time = 60
max_input_vars = 4440

You should also restart apache manually and verify the service status.

# service apache2 stop
# service apache2 start
# service apache2 status

Here is an example of the APache service status output.

● apache2.service – LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Mon 2018-04-23 00:02:09 -03; 1min 4s ago

Tutorial – Drupal Installation on Ubuntu

Now, we need to install the Drupal CMS on Ubuntu Linux.

On the Linux console, use the following commands to download the Drupal package.

# mkdir /downloads
# cd /downloads
# wget https://ftp.drupal.org/files/projects/drupal-8.6.4.tar.gz
# tar -zxvf drupal-8.6.4.tar.gz
# ls
drupal-8.6.4.tar.gz drupal-8.6.4

Move all the Drupal files to the root directory of your Apache installation.

Set the correct file permission on all moved files.

# mv drupal-8.6.4 /var/www/html/drupal
# chown www-data.www-data /var/www/html/drupal/* -R

Open your browser and enter the IP address your web server plus /drupal.

In our example, the following URL was entered in the Browser:

• http://35.162.85.57/drupal

The Drupal web installation interface should be presented.

Select the desired language.

Drupal installation

Select the Standard installation method.

Drupal installation mode

Enter the MySQL connection information to the Drupal database.

Drupal Database connection

Wait for the Drupal database installation process to finish.

On the next screen you will have to enter the following information:

• Your website Name.
• Your website E-mail.
• Your administrator username.
• Your administrator password.
• Your administrator e-mail account.
• Default Country
• Default Timezone

Drupal website information
Drupal website admin

After finishing the installation, you will be sent to the Drupal Dashboard.

Drupal Dashboard

Congratulations, you have installed the Drupal on Ubuntu Linux.