Atlantic.Net Blog

How to Install Drupal on Oracle Linux 8

Drupal is a powerful open-source content management system written in PHP. It is a simple and flexible CMS that helps beginner users to build and host a website without any coding knowledge. Drupal comes with a user-friendly web UI that helps you to manage your content, media, and other assets from a central location. It has a large, supportive community and is used by millions of people and organizations around the world.

In this tutorial, we will show you how to install Drupal CMS with Apache on Oracle Linux 8.

Also Read

Can Drupal Websites Be HIPAA-Compliant?

Step 1 – Install Apache and MariaDB Server

First, you will need to install an Apache webserver and MariaDB database server on your server. You can install both packages using the following command:

dnf install httpd mariadb-server curl unzip git -y

After successful installation, start the Apache and MariaDB service and enable them to start at system reboot:

systemctl start httpd
systemctl start mariadb
systemctl enable httpd
systemctl enable mariadb

Step 2 – Install PHP and Other Extensions

Next, it is recommended to install the latest version of PHP and other extensions to your server. By default, the latest version of PHP is not included in the Oracle Linux default repository, so you will need to install it from the Remi repository.

You can install the Remi repository with the following command:

dnf install epel-release -y
dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm

Once both repos are installed, reset the default PHP repository and enable the PHP 8.0 repository with the following command:

dnf module reset php
dnf module enable php:remi-8.0

Output:

Last metadata expiration check: 0:00:14 ago on Tuesday 03 May 2022 09:10:57 AM EDT.
Dependencies resolved.
==============================================================================================================================================
 Package                           Architecture                     Version                           Repository                         Size
==============================================================================================================================================
Enabling module streams:
 php                                                                remi-8.0                                                                 

Transaction Summary
==============================================================================================================================================

Is this ok [y/N]: y
Complete!

Next, install PHP 8 and other extensions using the following command:

dnf install php php-curl php-mbstring php-gd php-xml php-pear php-fpm php-mysql php-pdo php-opcache php-json php-zip php-soap php-xmlrpc -y

Once PHP and other packages are installed, verify the PHP version with the following command:

php -v

Output:

PHP 8.0.18 (cli) (built: Apr 13 2022 02:45:05) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.18, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.18, Copyright (c), by Zend Technologies

Next, edit the php.ini file and change some default settings:

nano /etc/php.ini

Change the following lines:

memory_limit = 256M
date.timezone = Asia/Kolkata

Save and close the file when you are finished.

Step 3 – Create a Database for Drupal

Drupal uses a MariaDB as a database backend, so you will need to create a database and user for Drupal. First, connect to the MariaDB with the following command:

mysql

Once you are connected, create a database and user using the following command:

CREATE DATABASE drupaldb;
GRANT ALL ON drupaldb.* TO 'drupaluser'@'localhost' IDENTIFIED BY 'securepassword';

Next, flush the privileges and exit from the MariaDB shell:

FLUSH PRIVILEGES;
EXIT;

Step 4 – Install Drupal

First, download the latest version of Drupal from its official website using the following command:

wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz

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

tar xvf drupal.tar.gz

Next, move the extracted directory to the Apache root directory:

mv drupal-9.3.12/  /var/www/html/drupal

Next, create a directory required for Drupal and copy a sample settings.php file:

mkdir /var/www/html/drupal/sites/default/files
cp /var/www/html/drupal/sites/default/default.settings.php /var/www/html/drupal/sites/default/settings.php

Next, set proper ownership and permission to the drupal directory:

chown -R apache:apache /var/www/html/drupal
chmod -R 755 /var/www/html/drupal

Step 5 – Create an Apache Virtual Host for Drupal

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

nano /etc/httpd/conf.d/drupal.conf

Add the following lines:

<VirtualHost *:80>
     ServerName drupal.example.com
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/drupal/

     CustomLog /var/log/httpd/access_log combined
     ErrorLog /var/log/httpd/error_log

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

Save and close the file, then restart the Apache service to apply the changes:

systemctl restart httpd

You can also check the status of Apache using the following command:

systemctl status httpd

You will get the following output:

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/httpd.service.d
           └─php-fpm.conf
   Active: active (running) since Tue 2022-05-03 09:15:34 EDT; 9s ago
     Docs: man:httpd.service(8)
 Main PID: 21883 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 213 (limit: 23694)
   Memory: 28.4M
   CGroup: /system.slice/httpd.service
           ├─21883 /usr/sbin/httpd -DFOREGROUND
           ├─21884 /usr/sbin/httpd -DFOREGROUND
           ├─21885 /usr/sbin/httpd -DFOREGROUND
           ├─21886 /usr/sbin/httpd -DFOREGROUND
           └─21887 /usr/sbin/httpd -DFOREGROUND

May 03 09:15:34 oraclelinux8 systemd[1]: httpd.service: Succeeded.
May 03 09:15:34 oraclelinux8 systemd[1]: Stopped The Apache HTTP Server.
May 03 09:15:34 oraclelinux8 systemd[1]: Starting The Apache HTTP Server...

Also Read

How to Setup Apache Virtual Hosting

Step 6 – Perform Drupal Web Installation

Now Drupal is installed and configured. You can access it using the URL http://drupal.example.com. You should see the following screen:
Drupal language selection
Select your Language and click on Save and continue button. You should see the following screen:
Drupal installation selection
Select an installation type and click on the Save and continue button. You should see the following screen:
Drupal database configuration
Provide your database information and click on the Save and continue button. Once the installation has been completed, you should see the following screen:
Drupal site configuration page1
Drupal site configuration page2
Provide your site information and click on the Save and Continue button. You should see the Drupal dashboard:
Drupal dashboard page

Conclusion

In this post, we explained how to install Drupal with Apache on Oracle Linux 8. You can now install Drupal on a live server and start creating your first website. Give it a try on your dedicated server from Atlantic.Net!

Get a $250 Credit and Access to Our Free Tier!

Free Tier includes:
G3.2GB Cloud VPS a Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year