How to install Drupal 9 on Fedora 34
Drupal is an open source content management system (cms) that is very flexible for building websites and applications. Approximately 2.5% of the world’s websites are using Drupal. Retail, e-commerce, healthcare and many other industries are using it.
Drupal has many features that make it unique. We have listed some of them here:
- With Drupal, websites can load very quickly and can scale according to increased traffic load.
- Drupal provides automatic language conversion based on regional geographic location. This helps deliver content in localized languages.
- With security features such as access control, encryption, and DoS mitigation, Drupal has proven to be a very secure and stable platform.
- Many marketing tools can be used to attract and track potential customers.
Now let us turn to the process of installing Drupal 9 on Fedora 34 OS. The current version available at the time of writing this tutorial is Drupal 9.0.+
Before we start…
Before starting the installation process, make sure that the following prerequisites are met:
- A user account with super user privileges.
- Access the internet.
Install Drupal 9 on Fedora 34 workstation
In this guide, we will install Drupal for PHP, Apache (httpd) web server, and MariaDB database server. It can also be installed with database servers such as SQLite, PostgresQL, MySQL, and Web servers such as Nginx and Microsoft IIS.
Step 1. Use the following command to install all required components and dependencies:
sudo dnf install httpd php php-mysqlnd php-gd php-xml mariadb-server mariadb php-mbstring php-json
Step 2. Start and enable Apache and MariaDB services:
sudo systemctl start httpd mariadb
sudo systemctl enable httpd mariadb
Set up MariaDB server
Step 1. For the first installation, please run the’mysql_secure_installation’ script to protect the database:
A series of the following questions will appear, please choose the setting that suits you:
Enter current password for user root: [Enter here]
Switch to unix_socket: [Y/n] [Enter n]
Change the root password? [Y/n] [Enter n]
Remove anonymous users? [Y/n] [Enter y]
Disallow root login remotely? [Y/n] [Enter y]
Remove test database and access to it? [Y/n] [Enter y]
Reload privilege tables now? [Y/n] [Enter y]
Step 2. After configuring MariaDB, we will create a database “test_db” and a user “test_user” with a password of “howtoforge”. Log in to MariaDB first, and then run subsequent commands to complete the following tasks:
sudo mysql -u root
1. Create a database named “test_db”:
create database test_db;
2. Create a user named “test_user”:
create user 'test_user'@'localhost' identified by 'howtoforge';
3. Provide the necessary permissions to the above-mentioned users:
grant all privileges on test_db.* to 'test_user'@'localhost';
4. Reload the authorization form:
5. Finally, use the following command to exit the database:
Set up the Apache web server
Step 1. Use the text editor of your choice to open the Apache configuration file:
sudo nano /etc/httpd/conf/httpd.conf
Step 2. Find the “Document root” entry and change it to look like this:
DocumentRoot "/var/www"<Directory "/var/www"> DirectoryIndex index.html index.html.var index.phpAllowoverride All
Setting up Drupal
Step 1. Now go to the Drupal website to download the latest version of Drupal (tar.gz) file. We will use the “wget” command to download the file as drupal.tar.gz.
wget -O drupal.tar.gz https://www.drupal.org/download-latest/tar.gz
Step 2. Go to the folder “/var/www” and extract the above files here:
sudo tar -zxf /home/fedora34w/drupal.tar.gz
In our example,’/home/fedora34w/’ is the download directory, change it to according to your download path.
Step 3. Create a symbolic link for the extracted drupal directory:
sudo ln -s drupal-9.1.7/ drupal
Step 4. Now go to the “drupal/sites/default” directory inside the “www” directory, and use the “cp” command to copy the default.settings.php file to settings.php:
sudo cp -p default.settings.php settings.php
Step 5. Create a folder named “files” in the same directory as settings.php (/var/www/drupal/sites/default):
sudo mkdir files
Step 6. To install Drupal, we need to set the permissions of “settings.php” to 777. This will make the file world readable, writable and executable.
sudo chmod 777 settings.php
After the installation is complete, for security reasons, we must reset this permission to 644.
The permissions of the “Files” folder need to be set to 775:
sudo chmod 775 files/
Step 7. Now, use the command to make “apache” the owner of the drupal directory:
sudo chown -R apache:apache /var/www/drupal-9.1.7
Step 8. Restart Apache and configure the firewall to allow HTTP communication:
sudo systemctl restart httpd
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
Step 9. We will temporarily disable SElinux during the Drupal installation process, and then re-enforce it after the installation:
sudo setenforce 0
Set up Drupal from your browser
1. Launch your web browser and navigate to your system IP followed by the “/drupal” label or use localhost instead of the IP address:
http://localhost/drupal or http://system_ip/drupal
2. The installation wizard will start immediately. Select the language from the drop-down list:
3. On the next page, select the standard profile option, because by default it has many configuration settings and various core modules are enabled. If you want to customize the function selection, you should use the minimal configuration file. The third option (“Umami Food Magazine”) is for demonstration purposes only.
4. On the next page, you will see if any dependencies or requirements are missing, otherwise, the installer will skip this page. If any components are missing or any errors, you can continue after the repair.
5. Next, use the radio button to select the database type, in our case MariaDB. Enter the database details (database name, database user name, database password). Press “Save and Continue” to start the installation process:
6. Drupal will start to install all its components, as shown in the figure below:
7. To complete the configuration of Drupal, please fill in the following details on the next page:
Site Name, Site email address, Username, Password, User’s Email address, Default country, Default time zone
After saving these details, the first page of your Drupal website will be displayed. You can add new pages and content to your website here:
8. After completing the above steps, restore the permissions of settings.php to 644, and then execute the SElinux policy again:
$ sudo chmod 644 settings.php
$ sudo setenforce 1
Congratulations, this completes the guide for installing Drupal 9 on Fedora 34 workstations. Drupal is a popular CMS platform used by many well-known companies. Try to use Drupal’s extensive feature set to build your personal website.