Drupal is a powerful content management system (CMS) used to build flexible and robust websites. In this guide, we will walk you through how to install Drupal 9 with Nginx and Let's Encrypt SSL on Debian 10. This setup provides a secure and high-performance environment for hosting your Drupal site, whether you're using a Windows VPS UK or other VPS hosting solutions.

Prerequisites

Before you begin, ensure you have the following:

Step 1: Update Your System

As always, start by updating your package list to ensure that all installed software is up to date. Run the following commands:

sudo apt update && sudo apt upgrade

Step 2: Install Nginx and PHP

Next, install the Nginx web server and the necessary PHP modules for running Drupal 9:

sudo apt install nginx php-fpm php-mysql php-xml php-json php-gd php-curl php-mbstring php-zip php-opcache php-xmlrpc

After the installation, start and enable Nginx:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 3: Install and Configure MySQL

Drupal requires a database to store its data. Install MySQL using the following command:

sudo apt install mysql-server

Once installed, secure your MySQL installation by running:

sudo mysql_secure_installation

Follow the prompts to set up a secure MySQL environment. After securing MySQL, log in and create a database for Drupal:

sudo mysql -u root -p
CREATE DATABASE drupaldb;
CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON drupaldb.* TO 'drupaluser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 4: Download and Configure Drupal 9

Now, download the latest version of Drupal 9. You can do this by navigating to the web root and downloading Drupal:

cd /var/www
sudo wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
sudo tar -xvzf drupal.tar.gz
sudo mv drupal-* drupal

Next, set the correct file permissions for Drupal to ensure that Nginx and PHP can access the necessary files:

sudo chown -R www-data:www-data /var/www/drupal
sudo chmod -R 755 /var/www/drupal

Step 5: Configure Nginx for Drupal

Create a new Nginx configuration file for your Drupal site:

sudo nano /etc/nginx/sites-available/drupal

Add the following configuration, replacing your-domain.com with your actual domain name:

server {
    listen 80;
    server_name your-domain.com;
    root /var/www/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.3-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

Save and close the file, then enable the site and restart Nginx:

sudo ln -s /etc/nginx/sites-available/drupal /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Step 6: Install Let's Encrypt SSL

To secure your site with SSL, you can use Let's Encrypt, a free and open certificate authority. First, install Certbot, the Let's Encrypt client:

sudo apt install certbot python3-certbot-nginx

Next, obtain an SSL certificate for your domain:

sudo certbot --nginx -d your-domain.com

Follow the prompts to complete the SSL certificate installation. Certbot will automatically configure Nginx to use the SSL certificate. After that, you can verify that SSL is working by visiting your site using https://your-domain.com.

Step 7: Complete the Drupal Installation

Now, visit your domain in a web browser to complete the Drupal setup. Navigate to http://your-domain.com, and you will see the Drupal installation wizard. Follow the prompts to connect to the database you created earlier and complete the installation.

Conclusion

By following these steps, you have successfully installed Drupal 9 with Nginx and Let's Encrypt SSL on Debian 10. This setup ensures that your site is secure and optimized for performance. Whether you're hosting your Drupal site on a Windows VPS UK or another Windows VPS Hosting UK solution, this guide will help you get started with your Drupal project.

Was dit antwoord nuttig? 0 gebruikers vonden dit artikel nuttig (0 Stemmen)