Moodle is a popular open-source learning management system (LMS) used to create online learning sites. In this guide, we will walk through the process of installing Moodle on Ubuntu 22.04, using Nginx as the web server and securing it with a free SSL certificate from Let's Encrypt. This setup is ideal for users running Moodle on local servers or on a Windows VPS UK.

Step 1: Update Your System

Before installing any new software, ensure that your system is up to date. Run the following commands to update your package lists and install any available updates:

sudo apt update && sudo apt upgrade -y

Keeping your system updated ensures stability and security, especially when using platforms like VPS Windows Servers.

Step 2: Install Nginx, MySQL, and PHP

Moodle requires a web server, a database, and PHP. Install Nginx, MySQL, and PHP with the following command:

sudo apt install nginx mysql-server php-fpm php-mysql php-xml php-zip php-gd php-intl php-curl php-mbstring -y

After installing these packages, start and enable Nginx and MySQL:

sudo systemctl start nginx
sudo systemctl enable nginx

sudo systemctl start mysql
sudo systemctl enable mysql

Step 3: Configure MySQL Database for Moodle

Log in to the MySQL shell to create a new database and user for Moodle:

sudo mysql -u root -p

Inside the MySQL shell, run the following commands to create the Moodle database and a user:

CREATE DATABASE moodledb DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON moodledb.* TO 'moodleuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace your_password with a strong password of your choice.

Step 4: Download and Install Moodle

Navigate to the /var/www/html directory and download the latest Moodle package:

cd /var/www/html
sudo wget https://download.moodle.org/download.php/direct/stable310/moodle-latest-310.tgz

Extract the downloaded archive:

sudo tar -zxvf moodle-latest-310.tgz

Set the correct ownership and permissions for the Moodle directory:

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

Step 5: Configure Nginx for Moodle

Next, create a new Nginx server block configuration for Moodle:

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

Add the following configuration:

server {
    listen 80;
    server_name yourdomain.com;

    root /var/www/html/moodle;
    index index.php index.html index.htm;

    location / {
        try_files $uri $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 ~* \.html$ {
        expires 5d;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires 30d;
        log_not_found off;
    }
}

Save and close the file, then enable the configuration by creating a symbolic link:

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

Test the Nginx configuration and reload the service:

sudo nginx -t
sudo systemctl reload nginx

Step 6: Obtain Free Let's Encrypt SSL

To secure Moodle with HTTPS, use Let's Encrypt to obtain a free SSL certificate. First, install Certbot:

sudo apt install certbot python3-certbot-nginx -y

Run the following command to obtain and install the SSL certificate:

sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Follow the prompts to complete the SSL setup. Certbot will automatically configure your Nginx server block to use the new SSL certificate.

Step 7: Complete Moodle Installation

Open your web browser and navigate to https://yourdomain.com to complete the Moodle installation through the web interface. Follow the on-screen instructions to set up Moodle, providing the database details configured earlier.

You have successfully installed Moodle with Nginx and secured it with a Let's Encrypt SSL certificate on Ubuntu 22.04. This setup ensures a secure and reliable e-learning platform for your users. For scalable hosting solutions, consider using Windows VPS UK. They offer a variety of hosting options, including windows virtual private servers, vps windows hosting, and windows virtual dedicated server hosting. Whether you're looking for windows vps italy or uk vps windows, their services provide the performance and scalability needed for your Moodle platform.

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