Drupal is a powerful and widely used content management system (CMS) that allows individuals and organizations to create and manage websites efficiently. In this comprehensive guide, we will walk you through the step-by-step process of installing Drupal on a Debian 12 server. By following these instructions, you will be able to set up a fully functional Drupal website and unleash its potential for your online presence.
1. Preparing the Environment
Before we dive into the installation process, let’s ensure that our environment is up to date and properly secured.
Updating the System
To begin, we need to update the system packages to the latest versions. Open the terminal and execute the following command:
sudo apt update -y sudo apt upgrade -y
Installing MariaDB Database Server
Next, we will install the MariaDB database server, which is required by Drupal to store and retrieve data. Run the following command to install MariaDB:
sudo apt install -y mariadb-server mariadb-client
Securing the Database Server
Now that MariaDB is installed, we need to secure it by setting a root password, disabling remote root logins, and removing test databases. Execute the following command to initiate the MySQL secure installation process:
sudo mysql_secure_installation
Follow the prompts and answer the questions to set a root password, remove anonymous users, disallow remote root login, remove the test database, and reload the privilege tables.
2. Creating a Database for Drupal
With the database server secured, we can now create a database specifically for Drupal. Log in to the MariaDB server as the root user using the following command:
mysql -u root -p
Enter the root password you set during the secure installation process. Once logged in, execute the following commands to create a database and a dedicated user for Drupal:
CREATE DATABASE drupal; CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'StrongPassword'; GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost'; FLUSH PRIVILEGES;
Make sure to replace ‘StrongPassword’ with a unique and secure password for the Drupal user. Exit the MySQL prompt by typing q
and pressing Enter.
3. Installing PHP
Drupal relies on PHP to execute its code and render web pages. Install PHP and the required PHP extensions by running the following command:
sudo apt install php php-cli php-fpm php-json php-common php-mysql php-gd php-intl php-mbstring php-zip php-curl php-xml php-pear php-soap php-tidy php-xmlrpc php-bcmath
4. Installing Apache Web Server
To serve the Drupal website, we need to install the Apache web server. Use the following command to install Apache:
sudo apt install apache2 libapache2-mod-php
5. Updating PHP Timezone and Memory Limit
To ensure that Drupal functions correctly, we need to update the PHP timezone and memory limit. Open the PHP configuration file using a text editor of your choice. For example:
sudo vi /etc/php/*/apache2/php.ini
Locate the memory_limit
and date.timezone
directives and modify them as follows:
memory_limit = 256M date.timezone = America/New_York
Save the changes and exit the text editor.
6. Downloading and Extracting Drupal
Now, let’s download the latest version of Drupal and extract it to the appropriate directory. Run the following commands:
wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz tar xvf drupal.tar.gz mv drupal-* /var/www/html/drupal
7. Configuring Ownership and Permissions
To ensure that the web server can access and modify the Drupal files, we need to update the ownership and permissions. Execute the following commands:
sudo chown -R www-data:www-data /var/www/html/drupal sudo chmod -R 755 /var/www/html/drupal
8. Configuring Apache Web Server for Drupal
To configure Apache to serve the Drupal website, we need to create a virtual host configuration file. Use a text editor to create the file:
sudo vi /etc/apache2/sites-available/drupal.conf
Add the following content to the file, replacing example.com
with your actual domain name:
<VirtualHost *:80>
ServerName mysite.com
ServerAlias www.example.com
ServerAdmin admin@example.com
DocumentRoot /var/www/html/drupal/
CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorLog ${APACHE_LOG_DIR}/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 the file and exit the text editor.
9. Enabling the Website
Now, we need to enable the newly created virtual host and disable unnecessary Apache modules. Execute the following commands:
sudo a2dismod mpm_event sudo a2enmod mpm_prefork sudo a2enmod php7.* sudo a2enmod rewrite sudo a2ensite drupal.conf sudo systemctl restart apache2
10. Setting Up Drupal
With the environment properly configured, we can now proceed to set up Drupal through the web browser.
Accessing the Drupal Configuration Page
Open your web browser and enter the URL http://example.com
, replacing example.com
with your actual domain name. You will be redirected to the Drupal installation page.
Selecting an Installation Profile
On the installation page, you will be prompted to choose an installation profile. Select the profile that best suits your needs and click on the “Save and continue” button.
Configuring the Database for Drupal
On the next page, enter the database details you previously configured. Provide the database name, username, and password. Click on the “Save and continue” button to proceed.
Completing the Installation
Finally, you will need to provide additional information to configure your site, such as the site name, site email, and administrator account details. Fill in the required fields and click on the “Save and continue” button.
Wait for the installation process to complete, and you will be redirected to the Drupal dashboard. Congratulations! You have successfully installed Drupal on your Debian 12 server.
11. Conclusion
In this comprehensive guide, we have walked you through the step-by-step process of installing Drupal on a Debian 12 server. By following these instructions, you have set up a powerful content management system that empowers you to create and manage your website efficiently. Drupal offers a wide range of features and customization options, allowing you to build a unique online presence.
Remember to regularly update Drupal and its modules to ensure the security and stability of your website. Should you encounter any issues or have questions, the Drupal community provides excellent support and resources to help you along the way.
For reliable and scalable cloud hosting solutions, consider Shape.host. Shape.host offers Linux SSD VPS hosting services, providing businesses with efficient, secure, and flexible infrastructure for their online operations. Experience the power of Shape.host and elevate your digital presence today!