Are you looking to build and maintain a powerful website using Drupal on your Rocky Linux 9 server? Drupal is a robust and flexible content management system (CMS) that allows you to create and publish dynamic web content with ease. In this comprehensive guide, we will walk you through the step-by-step process of installing Drupal on your Rocky Linux 9 server. By the end of this article, you will have a fully functional Drupal website up and running.
1. Introduction to Drupal
Drupal is a popular open-source content management system used by millions of individuals and organizations worldwide to build and maintain their websites. With its large and supportive community, Drupal offers a vast array of features and modules that allow you to customize your website according to your specific needs. Whether you’re a beginner or an experienced developer, Drupal provides an intuitive interface and powerful tools to create, organize, and publish content effortlessly.
2. Updating the System
Before diving into the installation process, it is essential to ensure that your Rocky Linux 9 server is up to date with the latest software packages. Updating your system helps to fix any vulnerabilities and ensures compatibility with the latest Drupal version. To update the system, open your terminal and execute the following command:
dnf update -y
3. Installing MariaDB Server
Next, you’ll need to install the MariaDB server, which is a widely used open-source relational database management system. MariaDB provides a robust and scalable database solution for your Drupal website. To install MariaDB server, run the following command:
dnf -y install mariadb
Once the installation is complete, enable the MariaDB service by executing the following command:
systemctl enable --now mariadb
To verify the status of the MariaDB service, use the following command:
systemctl status mariadb
If the output shows that the service is active and running, you have successfully installed MariaDB on your Rocky Linux 9 server.
4. Securing the MariaDB Server
Securing your database server is crucial to protect your Drupal website from unauthorized access. By setting a root password, disabling root remote logins, and removing test databases, you can enhance the security of your MariaDB server. To secure the MariaDB server, execute the following command:
mysql_secure_installation
Follow the on-screen prompts to set the root password, remove anonymous users, disallow root login remotely, and remove the test database. It is recommended to answer “Y” (yes) to all the prompts for maximum security.
5. Creating a Database for Drupal
To store and manage your Drupal website’s data, you need to create a dedicated database. Creating a separate database ensures the integrity and scalability of your website. To create a database for Drupal, log in to the MariaDB server with the following command:
mysql -u root -p
Enter the root password you set during the MariaDB server installation. Once logged in, execute the following SQL commands to create the Drupal database and grant all privileges to the Drupal user:
CREATE DATABASE drupal; GRANT ALL PRIVILEGES ON drupal.* TO drupal@'localhost' IDENTIFIED BY "StrongPassword"; FLUSH PRIVILEGES; exit
Replace “StrongPassword” with a strong and secure password of your choice. These commands will create a database named “drupal” and grant all privileges to the “drupal” user, allowing it to access and modify the database.
6. Installing PHP and Extensions
Drupal requires PHP to run its core functionalities. However, the default PHP version in Rocky Linux 9 may not be compatible with Drupal. To install a compatible version of PHP, you can refer to the official documentation for instructions on installing PHP 8.2 or higher.
Once you have installed the appropriate version of PHP, verify the installation by executing the following command:
php -v
If the output displays the correct PHP version, you have successfully installed PHP on your Rocky Linux 9 server.
7. Installing the Apache Webserver
To serve your Drupal website to the internet, you’ll need to install the Apache webserver. Apache is a widely used web server that provides the necessary infrastructure to deliver web content efficiently. Install the Apache webserver by running the following command:
dnf -y install httpd
After the installation is complete, start the Apache service and enable it to start automatically on system boot with the following command:
systemctl enable --now httpd
If you have the firewalld service running, you need to open port 80 to allow incoming HTTP requests. Use the following commands to open the necessary ports:
firewall-cmd --add-service=http --permanent firewall-cmd --reload
8. Configuring PHP Memory Limit
Drupal requires a sufficient amount of memory to run smoothly. By default, PHP may have a low memory limit, which can cause performance issues. To increase the PHP memory limit, edit the PHP configuration file using a text editor of your choice:
vi /etc/php.ini
Locate the memory_limit
variable and replace its value with 256M
to allocate 256 megabytes of memory. Save the file and exit the text editor.
9. Downloading and Installing Drupal
Now it’s time to download and install Drupal on your Rocky Linux 9 server. Start by navigating to the desired directory where you want to install Drupal. In this example, we will use the default Apache web root directory:
cd /var/www/html/
Next, download the latest version of Drupal using the wget
command:
wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
Once the download is complete, extract the downloaded file using the tar
command:
tar xvf drupal.tar.gz
This will create a new directory named drupal-x.x.x
(replace x.x.x
with the actual version number) containing the Drupal files. Rename this directory to drupal
using the following command:
mv drupal-x.x.x drupal
10. Setting File Permissions
To ensure that Apache can access and modify the Drupal files, you need to adjust the file permissions. Execute the following commands to change the ownership and permissions of the Drupal directory:
chown -R apache:apache /var/www/html/drupal chmod -R 755 /var/www/html/drupal
These commands will change the ownership of the Drupal directory to the Apache user and group and set the necessary permissions for Apache to read, write, and execute the files.
11. Configuring Apache Web Server for Drupal
To configure the Apache web server to serve your Drupal website, you need to create a virtual host configuration file. Open a text editor and create a new file named drupal.conf
in the /etc/httpd/conf.d/
directory:
vi /etc/httpd/conf.d/drupal.conf
Copy and paste the following configuration into the file:
<VirtualHost *:80> ServerName example.com ServerAdmin admin@example.com DocumentRoot /var/www/html/drupal/ <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>
Replace example.com
with your actual domain name or the server’s IP address. Save the file and exit the text editor.
Finally, restart the Apache web server to apply the configuration changes:
systemctl restart httpd
12. Checking and Installing Drupal
Congratulations! You have completed the installation and configuration process. Now, it’s time to check if Drupal is working correctly. Open a web browser and enter your server’s domain name or IP address (e.g., http://example.com
) in the address bar.
You will be greeted with the Drupal installation page. Follow the on-screen instructions to select an installation profile and configure your database settings. Once you have completed the installation, you will be redirected to the Drupal dashboard, where you can start creating and managing your website’s content.
Conclusion
In this comprehensive guide, we have covered the step-by-step process of installing Drupal on a Rocky Linux 9 server. By following these instructions, you can set up a powerful and flexible website using Drupal, taking advantage of its extensive features and modules. Remember to regularly update your Drupal installation and maintain the security of your server to ensure a smooth and secure website experience.
If you’re looking for reliable and scalable Cloud VPS hosting services, consider Shape.host. Shape.host offers a wide range of cloud hosting solutions, including Cloud VPS, that guarantee high performance, security, and scalability for your Drupal website. Visit Shape.host to explore their hosting options and take your website to new heights.