Drupal is a popular open-source content management system (CMS) known for its flexibility and scalability. In this guide, we will walk you through how to install Drupal with Nginx and secure it using Let's Encrypt SSL on Ubuntu 20.04 LTS. Whether you're hosting your website on a Windows VPS UK or any other VPS platform, this setup will help you build a secure and reliable Drupal website.
Prerequisites
Before you begin, ensure you have the following:
- An Ubuntu 20.04 LTS server, which could be hosted on a UK Windows VPS, Windows Virtual Private Servers, or another Windows VPS Hosting UK solution.
- A domain name pointed to your server's IP address.
- Root or sudo privileges on your server.
Step 1: Update Your System
Before installing any software, make sure your system is up to date:
sudo apt update && sudo apt upgrade -y
Step 2: Install Nginx
Install Nginx, which will serve as the web server for your Drupal site:
sudo apt install nginx -y
Start and enable Nginx to run at boot:
sudo systemctl start nginx
sudo systemctl enable nginx
Step 3: Install PHP and Required Extensions
Drupal requires PHP and specific PHP extensions to run. Install PHP 7.4 and the necessary extensions:
sudo apt install php-fpm php-mysql php-xml php-gd php-curl php-json php-mbstring php-zip php-xmlrpc -y
Step 4: Install MariaDB (or MySQL)
Drupal requires a database to store its content. Install MariaDB (or MySQL) using the following command:
sudo apt install mariadb-server -y
Once installed, secure your MariaDB installation:
sudo mysql_secure_installation
Log in to MariaDB and create a database and user for Drupal:
sudo mysql -u root -p
CREATE DATABASE drupal;
CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON drupal.* TO 'drupaluser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 5: Download and Install Drupal
Navigate to your web root directory and download the latest version of Drupal:
cd /var/www/html
sudo wget https://ftp.drupal.org/files/projects/drupal-9.3.0.tar.gz
Extract the Drupal archive and move the extracted files to a new directory:
sudo tar -zxvf drupal-9.3.0.tar.gz
sudo mv drupal-9.3.0 drupal
Set the correct ownership and 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 Nginx for Drupal
Create a new Nginx configuration file for Drupal:
sudo nano /etc/nginx/sites-available/drupal
Add the following configuration, replacing your-domain.com
with your actual domain:
server {
listen 80;
server_name your-domain.com www.your-domain.com;
root /var/www/html/drupal;
index index.php index.html index.htm;
location / {
try_files $uri /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Save and close the file, then enable the configuration by creating a symbolic link:
sudo ln -s /etc/nginx/sites-available/drupal /etc/nginx/sites-enabled/
Test the Nginx configuration and restart the service:
sudo nginx -t
sudo systemctl restart nginx
Step 7: Secure Drupal with Let's Encrypt SSL
To secure your Drupal site, use Let's Encrypt SSL. First, install Certbot:
sudo apt install certbot python3-certbot-nginx -y
Obtain an SSL certificate by running the following command:
sudo certbot --nginx -d your-domain.com -d www.your-domain.com
Follow the on-screen instructions to complete the process. Certbot will automatically configure Nginx to use SSL.
Step 8: Complete Drupal Installation
Now that Nginx and SSL are configured, open your web browser and navigate to https://your-domain.com
to complete the Drupal installation via the web interface. Enter your database details and set up your Drupal site.
Conclusion
By following these steps, you have successfully installed Drupal with Nginx and secured it with Let's Encrypt SSL on Ubuntu 20.04 LTS. Whether you are hosting your Drupal website on a Windows VPS UK, Windows VPS Italy, or another Windows Virtual Private Server Hosting solution, this setup ensures your site is fast, secure, and scalable.