How to Install Drupal 8 on CentOs 7 / Redhat (RHEL) 7
Enjoying this content? Subscribe to the Channel!
Mastering CMS: Installing Drupal 8 on CentOS 7 / RHEL 7 (Step-by-Step Guide)
Welcome back to Darren’s Tech Tutorials!
If you’re ready to build robust, scalable websites using one of the most powerful Content Management Systems (CMS) available, then you’ve come to the right place. Drupal 8 offers amazing flexibility, and today, we are going to show you exactly how to get it running smoothly on a CentOS 7 machine.
This detailed guide uses the same proven steps we cover in our latest YouTube tutorial, and the commands are also fully compatible if you are running Red Hat Enterprise Linux (RHEL) 7. Let’s dive in and transform your server into a powerful Drupal host!
Prerequisites Check
Before we begin the installation process, it is essential that your environment is properly configured. If you haven’t completed these steps yet, please pause and check out our supporting tutorials:
- A Clean CentOS 7 Installation: We need a functioning server environment.
- Need help? See our installation guide here:
https://youtu.be/qZXZepdUjRI
- Need help? See our installation guide here:
- Apache Web Server Installed: Drupal needs a web server to function.
- Need help? See how to install and configure Apache here:
https://youtu.be/rs0tCdkd5Bk
- Need help? See how to install and configure Apache here:
Ready? Let’s start installing the necessary components!
Step 1: Installing Essential PHP Modules and Dependencies
Drupal 8 is built on PHP, and it requires several specific modules to run correctly and efficiently. While CentOS 7 ships with older PHP versions, we need to ensure we have the necessary extensions available.
We highly recommend using the Remi repository to access updated PHP versions.
First, install the EPEL and Remi repositories:
sudo yum install epel-release -y
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Next, install PHP and all the necessary modules required by Drupal (we’ll enable PHP 7.x, as it’s better for Drupal 8):
sudo yum install yum-utils
sudo yum-config-manager --enable remi-php72 # Use a stable PHP 7 version
sudo yum install php php-cli php-mysql php-gd php-ldap php-odbc php-pdo php-opcache php-xml php-mbstring php-json -y
Finally, restart the Apache service to load the new PHP configurations:
sudo systemctl restart httpd
Step 2: Setting Up the MariaDB Database
Drupal needs a database to store all its content, user information, and configurations. We will be using MariaDB, the default robust database system for CentOS 7.
Start by securing your MariaDB installation:
sudo mysql_secure_installation
(Follow the prompts to set the root password and secure your installation.)
Now, log into the MariaDB shell and create the specific database and user for Drupal. We’ll call our database drupaldb and our user darrenuser.
mysql -u root -p
(Enter the root password you just set)
CREATE DATABASE drupaldb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'darrenuser'@'localhost' IDENTIFIED BY 'YourStrongPasswordHere';
GRANT ALL PRIVILEGES ON drupaldb.* TO 'darrenuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Security Note: Make sure you choose a strong, unique password for the
darrenuser.
Step 3: Downloading and Placing the Drupal Core Files
With the dependencies and database ready, it’s time to download the Drupal core package and place it into our web root directory (/var/www/html/).
Navigate to the temporary directory, download the stable Drupal 8 release (we use the tar.gz file), and then extract it:
cd /tmp
wget https://ftp.drupal.org/files/projects/drupal-8.9.20.tar.gz
tar -zxvf drupal-8.9.20.tar.gz
(Note: Replace the version number above with the latest stable Drupal 8 release if necessary.)
Now, move the extracted files into the designated web directory. We’ll place it in a dedicated folder named drupal8:
sudo mv drupal-8.9.20 /var/www/html/drupal8
Step 4: Configuring Permissions and SELinux
This is a critical step! For Apache to be able to read, write, and execute the necessary files during the installation process, we must correct the file ownership and set the correct permissions.
Change the ownership of the new drupal8 directory to the Apache user (apache):
sudo chown -R apache:apache /var/www/html/drupal8
Next, update the permissions:
sudo chmod -R 755 /var/www/html/drupal8
If you have SELinux enabled (which is the default and recommended for security on CentOS 7), you will need to adjust the security contexts so Apache can interact with the files:
sudo chcon -R -t httpd_sys_rw_content_t /var/www/html/drupal8
Step 5: Finalizing the Installation via the Web Interface
All the heavy lifting on the command line is complete! You can now launch your web browser and navigate to the final installation screens.
Open your browser and enter your server’s IP address followed by the new Drupal directory:
http://[Your Server IP Address]/drupal8
You will be greeted by the Drupal installation wizard. Simply follow these steps:
- Choose Language: Select your desired language.
- Select Installation Profile: Choose “Standard.”
- Database Configuration: Enter the database details you created in Step 2:
- Database name:
drupaldb - Database user:
darrenuser - Database password:
YourStrongPasswordHere
- Database name:
- Site Configuration: Set your desired site name, administrator email, username, and password.
Once the installation is complete, you will be redirected to the new Drupal 8 administration dashboard!
Conclusion: Start Building with Drupal 8!
Congratulations! You have successfully navigated the complexities of installing Drupal 8 on a stable CentOS 7 platform. This setup provides a secure, powerful foundation for any website or application you wish to build.
Drupal 8 is incredibly flexible and ready to handle whatever you throw at it. Now is the perfect time to start exploring modules and customizing your new CMS!
Did these steps work for you? Let us know in the comments below! If you found this guide helpful, please Like this post and Subscribe to Darren’s Tech Tutorials for more clear, actionable guides on making technology work for you. Happy coding!