How to install Drupal 8 on Fedora

Drupal is a completely free and open source content management system. It’s also one of the most popular open source projects ever. Drupal reportedly runs about 2.5% of the world’s websites. Best of all, it’s available for easy installation on your Fedora system.

Install the packages

Fedora provides a set of pre-packaged software to make installation easy. Open a terminal, and at the command prompt, use sudo to install the following packages.

sudo dnf install @"Web Server" drupal8 drupal8-httpd php-opcache php-mysqlnd mariadb-server

This example assumes you’ll run the web and database servers on the same machine. This is often the case for students and developers alike.

Enable the web and database services to start at boot time, then start them immediately:

sudo systemctl enable httpd.service mariadb.service
sudo systemctl start httpd.service mariadb.service

Set up the database server

If this is your first use of MariaDB, you should create a password for your root user. Store it somewhere secure and safe, in case you forget it. Don’t use the system’s own root (administrator) password.

sudo mysqladmin -u root password

Next, create a database. You can host more than one Drupal site on a machine. Therefore, you may want to choose a distinctive name for yours. For instance, this example uses myd8site. The -p switch prompts you for a password. You’ll need that, since you’ve added a password for root.

sudo mysqladmin create myd8site -u root -p

Next, set up a special privileged user and password for the database. The Drupal web app uses these credentials to run. Use the standard mysql client program for this step. The -D mysql option attaches to the built-in mysql database where privileges are stored.

Your input is shown in boldface in the example below. Make sure to use a strong password and not password itself.

$ sudo mysql -D mysql -u root -p
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.1.18-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [mysql]> GRANT ALL PRIVILEGES ON myd8site.* TO 'sqluser'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

MariaDB [mysql]> QUIT;

Set up the web server

Next, tune the SELinux parameters so the web server can perform necessary functions.

sudo setsebool -P httpd_can_network_connect_db=1
sudo setsebool -P httpd_can_sendmail=1

If desired, change the file /etc/httpd/conf.d/drupal8.conf so other systems can visit the site. Change the Require local line, so it reads Require all granted instead. Check the file after you run this command to confirm the change:

sudo sed -i 's/Require local/Require all granted/' /etc/httpd/conf.d/drupal8.conf

Next, configure your firewall so it allows traffic on port 80 (HTTP):

sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload

Now, copy the default settings file to a site-specific file, settings.php. Then make it world-writable. (You’ll change this back in a few minutes.)

sudo cp /etc/drupal8/sites/default/default.settings.php /etc/drupal8/sites/default/settings.php
sudo chmod 666 /etc/drupal8/sites/default/settings.php

Finally, restart the web server:

systemctl restart httpd

Visit the Drupal site

Next, you’re ready to configure the web app itself. Open a web browser on the system, or a connected system. Then browse to the IP address of your Drupal host, followed by /drupal8. For instance, your URL might be If you’re on the same box, you can use http://localhost/drupal8. This step begins the setup process:

Drupal 8 initial installation screen

Follow the prompt to choose a language, then save and continue. Most people choose a Standard installation profile. That profile provides more features right away.

When you get to the database configuration screen, use the hostname localhost. (If you already have another database host, use its hostname instead.) Enter the privileged MariaDB user and password you created for Drupal 8.


Drupal 8 installation - database configuration

When you save the database information, the site settings are configured for you. After the installation is done, change the settings.php file’s permissions back to normal:

sudo chmod 644 /etc/drupal8/sites/default/settings.php

Finish the process in the last screen by adding the site name and other site information.

Using Software

1 Comment

  1. Thank you for this. I recently moved away from another distribution where whoever was taking care of GNOME wasn’t doing it right thus plenty weird bugs. Fedora 25 has blown my mind, I haven’t been this happy in a long time with a distribution.

    This article fits nicely since I wanted to work with Drupal, you know, start creating sites and stuff. Have you ever had problems with SELinux permissions (filesystem, not apache) and drupal? I had to switch context objects of a file over to httpd. Now, I don’t know much about security contexts when it comes to SELinux, but I worry I have to be doing this over and over again every time I introduce files into a theme or module for Drupal, or whatever PHP script I’m creating or running.

    Anyway, to those following the tutorial, don’t forget to install Xdebug and configure it. It’s incredibly useful. (Using it along with Visual Studio Code)

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions