Moodle is a powerful open-source learning management system (LMS) widely used for online learning and educational institutions. In this guide, we will walk you through the process of installing Moodle on Ubuntu 20.04 with Nginx as the web server and securing it using Let's Encrypt SSL. If you're hosting your site on a Windows VPS UK, similar configurations apply, though this tutorial focuses on Ubuntu 20.04.

Prerequisites

Before we begin, ensure you have the following:

  • An Ubuntu 20.04 server with root or sudo access.
  • A registered domain name.
  • Nginx installed on your server.
  • MySQL or MariaDB database server installed.
  • PHP and required extensions installed.

If you're using a VPS UK Windows, you can still run Moodle by configuring a virtual environment for Ubuntu on your Windows-based server. Hosting Moodle on Windows VPS ensures better performance and reliability with dedicated resources.

Step 1: Update Your System

Begin by updating your Ubuntu 20.04 system packages:

sudo apt update
sudo apt upgrade -y

Step 2: Install Nginx

To install Nginx, use the following command:

sudo apt install nginx -y

Once installed, start and enable Nginx:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 3: Install PHP and Required Extensions

Moodle requires PHP and several extensions to function properly. Install PHP and the required extensions by running:

sudo apt install php-fpm php-mysql php-curl php-xml php-gd php-intl php-xmlrpc php-zip php-mbstring php-soap php-bcmath -y

Step 4: Install and Configure MySQL

Next, install MySQL to manage the Moodle database:

sudo apt install mysql-server -y

Once installed, secure your MySQL installation:

sudo mysql_secure_installation

Create a database and user for Moodle:

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

Step 5: Download and Configure Moodle

Download the latest version of Moodle from the official website:

sudo apt install git -y
cd /var/www/
sudo git clone https://github.com/moodle/moodle.git
cd moodle
sudo git branch --track MOODLE_39_STABLE origin/MOODLE_39_STABLE
sudo git checkout MOODLE_39_STABLE

Set the appropriate permissions:

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

Step 6: Configure Nginx for Moodle

Next, configure Nginx to serve the Moodle site. Create a new Nginx configuration file:

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

Add the following configuration:

server {
    listen 80;
    server_name yourdomain.com;
    root /var/www/moodle;

    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 ~* ^/vendor/.*\.php$ {
        deny all;
    }

    location ~* ^/node_modules/.*\.php$ {
        deny all;
    }

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

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

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

Step 7: Install Let's Encrypt SSL

To secure your Moodle site, install Let's Encrypt SSL using Certbot:

sudo apt install certbot python3-certbot-nginx -y

Obtain and install your SSL certificate:

sudo certbot --nginx -d yourdomain.com

Follow the prompts to complete the SSL installation. Certbot will automatically configure Nginx to use HTTPS.

Step 8: Complete Moodle Installation

Open your browser and navigate to https://yourdomain.com to complete the Moodle installation via the web interface. Follow the on-screen instructions to configure the database and complete the setup.

Benefits of Hosting Moodle on a VPS

Hosting Moodle on a Windows VPS provides dedicated resources and enhanced performance. Whether you choose a UK Windows VPS or Windows VPS Italy, using a Windows Virtual Private Server Hosting solution ensures better scalability and flexibility for educational institutions.

Consider using Windows Virtual Dedicated Server Hosting for a more powerful hosting environment, ideal for handling high traffic and managing multiple users in a Moodle instance.

Conclusion

By following this guide, you can successfully install Moodle with Nginx and Let's Encrypt SSL on Ubuntu 20.04. This setup ensures that your Moodle site is secure and performs optimally. For enhanced performance, consider using Windows VPS Hosting UK to take advantage of scalable and reliable hosting solutions.

© 2024 VPS Hosting Solutions

Hai trovato utile questa risposta? 0 Utenti hanno trovato utile questa risposta (0 Voti)