Idroot Us Install Moodle With Lemp Stack Ubuntu 22 04
Idroot Us Install Moodle With Lemp Stack Ubuntu 22 04
22.04 LTS
UBUNTU, UBUNTU BASED • JULY 20, 2022 10:09
In this tutorial, we will show you how to install Moodle with LEMP Stack on Ubuntu 22.04 LTS. For those of you
who didn’t know, Moodle is a free and open-source Learning Management System and CMS written in PHP. With
Moodle, you can create a fully-featured website for education and training courses, suitable for fully online,
hybrid, and in-person classroom experiences. The Moodle platform is highly customizable and takes a modular
approach to features, so it is extensible and adaptable to your needs. Moodle comes in handy, particularly for
Long-distance institutions across the globe in providing training material for their learners.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most
importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in
the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the
step-by-step installation of Moodle with LEMP Stack on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same
instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS,
and more as well.
Prerequisites
A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based
distribution like Linux Mint.
It’s recommended that you use a fresh OS install to prevent any potential issues.
SSH access to the server (or just open Terminal if you’re on a desktop).
A non-root sudo useror access to the root user. We recommend acting as a non-root sudo
user, however, as you can harm your system if you’re not careful when acting as the root.
Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com
sudo apt update
sudo apt upgrade
sudo apt install software-properties-common dirmngr
Before starting this tutorial, the LEMP server must be installed on your server. If you do not have LEMP
Stack installed, you can follow our guide here.
By default, Moodle is not available on Ubuntu 22.04 base repository. Now run the following command
below to download the latest stable version of Moodle to your Ubuntu system:
cd /var/www/html
git clone -b MOODLE_400_STABLE git://git.moodle.org/moodle.git moodle
mkdir -p /var/www/html/moodledata
chown -R www-data:www-data /var/www/html/moodle
chmod -R 755 /var/www/html/*
chown www-data:www-data /var/www/html/moodledata
By default, MariaDB is not hardened. You can secure MariaDB using the
mysql_secure_installation script. you should read and below each step carefully which will set a
root password, remove anonymous users, disallow remote root login, and remove the test database and
access to secure MariaDB:
mysql_secure_installation
Next, we will need to log in to the MariaDB console and create a database for Moodle. Run the following
command:
mysql -u root -p
Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com
This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are
logged in to your database server you need to create a database for Moodle installation:
nano /etc/nginx/conf.d/wordpress.conf
server {
listen 80;
root /var/www/html/moodle;
index index.php index.html index.htm;
server_name your-domian.com;
client_max_body_size 500M;
location / {
try_files $uri $uri/ /index.php?$args;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \.php$ {
Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Save and close the file then, restart the Nginx web server so that the changes take place:
nginx -t
sudo systemctl restart nginx
sudo systemctl restart php8.1-fpm
After complete install Certbot, now we set up Certbot for Nginx using the following command:
Next, run the following command to start the creation of your certificate:
Output:
-------------------------------------------------------------------------------
Congratulations! You have successfully enabled https://domain.com and
https://www.your-domain.com
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/your-domain.com/fullchain.pem
Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com
Your key file has been saved at:
/etc/letsencrypt/live/your-domain.comm/privkey.pem
Your cert will expire on 2022-07-20. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:
Let’s Encrypt certificates have 90 days of validity, and it is highly advisable to renew the certificates before
they expire. To test that this renewal process is working correctly, you can run:
Output:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/your-domain.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account registered.
Simulating renewal of an existing certificate for your-domain.com and www.your-
domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded:
/etc/letsencrypt/live/domain.com/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ubuntu 22.04 has ufw a firewall running by default. Enable connection through ports 80 HTTP and 443
HTTPS:
Once successfully installed, open your web browser and access the Moodle installation wizard using the
URL https://your-domain.com. You will be redirected to the following page:
Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com
Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com
Congratulations! You have successfully installed Moodle. Thanks for using this tutorial for installing Moodle with
LEMP on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend
you check the official Moodle website.
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service
to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the
best deal!
TAGS: MOODLE
Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com