Install Moodle on ubuntu 22.04

Install Moodle on ubuntu 22.04

$sudo apt update -y && sudo apt upgrade -y
$sudo apt install nginx mariadb-server -y
$sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https -y
$sudo add-apt-repository ppa:ondrej/php
$sudo apt update -y && sudo apt upgrade -y
$sudo apt install php7.4 php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-soap php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip unzip git curl -y

$sudo nano /etc/php/7.4/fpm/php.ini
memory_limit = 256M
max_input_vars = 6000

cgi.fix_pathinfo = 0
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = UTC

$sudo systemctl restart php7.4-fpm

$sudo mysql -u root -p

MariaDB>CREATE DATABASE moodledb;
MariaDB>CREATE USER 'moodle'@'localhost' IDENTIFIED BY 'password';
MariaDB>GRANT ALL ON moodledb.* TO 'moodle'@'localhost' WITH GRANT OPTION;
MariaDB>FLUSH PRIVILEGES;
MariaDB>EXIT;

$sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Add the following lines inside the [mysqld] section:

[mysqld]
innodb_file_format = Barracuda
innodb_file_per_table = 1
innodb_large_prefix = ON

$sudo systemctl restart mariadb

$cd /var/www
$sudo git clone -b MOODLE_400_STABLE git://git.moodle.org/moodle.git moodle
$sudo mkdir -p /var/www/moodledata
$sudo chown -R www-data:www-data /var/www/moodle
$sudo chmod -R 755 /var/www/*
$sudo chown www-data:www-data /var/www/moodledata

$sudo nano /etc/nginx/conf.d/moodle.conf
server {
listen 80;
root /var/www/moodle;
index index.php index.html index.htm;
server_name [your URL, i.e. moodle.kku.net];

client_max_body_size 100M;
autoindex off;
location / {
try_files $uri $uri/ =404;
}

location /dataroot/ {
internal;
alias /var/www/moodledata/;
}

location ~ [^/].php(/|$) {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

$sudo nginx -t
$sudo systemctl restart nginx

Access your URL to config
language -> English
directory -> check for accuracy
database -> MariaDB
database host -> localhost
database name -> moodledb
database user -> moodle
database password -> [Your password]

Install........

Set up admin account
Set up site settings
Register your site through moodle

And then you're ready


Add Let's encrypt SSL

$sudo apt install python3-certbot-nginx -y
$ sudo certbot --nginx -d your-domain-url

$cd /var/www/moodle
$sudo nano config.php

change $cfg->wwwroot from http to https