Drupal is a powerful and flexible open-source content management system (CMS) that allows you to create and manage a variety of websites. In this guide, we will walk you through the installation of Drupal on Ubuntu 22.04 using Apache2 as the web server. Whether you are deploying it on a local server or using a Windows VPS UK, this tutorial provides all the necessary steps.
Step 1: Update Your System
Before installing Drupal, ensure your system is up to date. Run the following commands:
sudo apt update && sudo apt upgrade -y
Keeping your system updated is crucial for security and performance, whether you're setting it up locally or on a VPS Windows Servers platform.
Step 2: Install Apache2, MySQL, and PHP
Drupal requires a web server, a database, and PHP. Install Apache2, MySQL, and the required PHP extensions by running:
sudo apt install apache2 mysql-server php php-mysqli php-curl php-xml php-gd php-mbstring php-zip php-soap php-intl -y
After installation, enable and start the Apache and MySQL services:
sudo systemctl enable apache2
sudo systemctl start apache2
sudo systemctl enable mysql
sudo systemctl start mysql
Step 3: Configure MySQL Database
Log in to MySQL to create a database and user for Drupal:
sudo mysql -u root -p
Create a database and user with the following commands:
CREATE DATABASE drupal_db;
CREATE USER 'drupal_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON drupal_db.* TO 'drupal_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Replace your_password
with a secure password of your choice.
Step 4: Download Drupal
Navigate to the web root directory and download the latest version of Drupal:
cd /var/www/html
sudo wget https://www.drupal.org/download-latest/tar.gz
sudo tar -xvzf tar.gz
sudo mv drupal-* drupal
Remove the downloaded tar file:
sudo rm tar.gz
Step 5: Set Permissions
Set the proper permissions for the Drupal files:
sudo chown -R www-data:www-data /var/www/html/drupal
sudo chmod -R 755 /var/www/html/drupal
Step 6: Configure Apache for Drupal
Create a new Apache configuration file for Drupal:
sudo nano /etc/apache2/sites-available/drupal.conf
Add the following configuration, replacing your-domain.com
with your actual domain:
ServerAdmin admin@your-domain.com
DocumentRoot /var/www/html/drupal
ServerName your-domain.com
ServerAlias www.your-domain.com
AllowOverride All
Require all granted
ErrorLog ${APACHE_LOG_DIR}/drupal_error.log
CustomLog ${APACHE_LOG_DIR}/drupal_access.log combined
Save and exit the file, then enable the new site and the required Apache modules:
sudo a2ensite drupal.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Step 7: Access Drupal Installation Wizard
Open your web browser and navigate to:
http://your-domain.com
You should see the Drupal installation wizard. Follow the on-screen instructions to complete the installation process, including setting up your database connection using the credentials created earlier.
Step 8: Secure Drupal with Let's Encrypt SSL
To secure your Drupal installation with SSL, use Let's Encrypt. Install Certbot:
sudo apt install certbot python3-certbot-apache -y
Run Certbot to obtain and install the SSL certificate:
sudo certbot --apache -d your-domain.com -d www.your-domain.com
Certbot will automatically configure SSL for your Drupal instance, ensuring secure access to the platform, whether it is hosted locally or on a Windows VPS hosting UK.