This guide provides a complete step-by-step process to install Moodle 4.4.11 on Amazon EC2 running Amazon Linux 2023. This documentation covers everything from EC2 instance creation to a fully functional Moodle Learning Management System.
- AWS Account with EC2 access
- Basic knowledge of AWS console
- SSH client (Terminal, PuTTY, etc.)
- Login to AWS Console β Navigate to EC2
- Click "Launch Instance"
- Choose AMI: Amazon Linux 2023 (64-bit x86)
- Instance Type: t2.medium (recommended for production)
- Key Pair: Create new or select existing
- Network Settings:
- VPC: Use default VPC or create new
- Subnet: Default or specific subnet
- Auto-assign public IP: Enable
- Storage: 20GB minimum (gp3 recommended)
- Security Group: Create new with these rules:
- SSH (22) - Your IP
- HTTP (80) - 0.0.0.0/0
- HTTPS (443) - 0.0.0.0/0
- Launch Instance
# Replace with your key file and public IP
ssh -i "your-key.pem" ec2-user@YOUR_PUBLIC_IPsudo dnf update -y# Install Apache, PHP, Git, and other essentials
sudo dnf install -y httpd php php-cli php-fpm php-mysqlnd php-xml php-soap php-intl php-zip php-gd php-mbstring php-opcache php-pdo git memcached
# Start and enable services
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl start memcached
sudo systemctl enable memcached# Download MySQL repository
sudo wget https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm
# Install MySQL repository
sudo dnf install mysql80-community-release-el9-1.noarch.rpm -y
# Import GPG key
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
# Install MySQL
sudo dnf install mysql-community-server -y
# Start and enable MySQL
sudo systemctl start mysqld
sudo systemctl enable mysqld# Get temporary password
sudo grep 'temporary password' /var/log/mysqld.log
# Run security script
sudo mysql_secure_installation
# Use strong password# Login to MySQL
sudo mysql -u root -p
# Create database and user
CREATE DATABASE moodledb DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'Moodle2025!@#';
GRANT ALL PRIVILEGES ON moodledb.* TO 'moodleuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;# Navigate to web root
cd /var/www
# Clone Moodle (latest stable)
sudo git clone -b MOODLE_404_STABLE https://github.com/moodle/moodle.git
# Set permissions
sudo chown -R apache:apache /var/www/moodle
sudo chmod -R 755 /var/www/moodle
# Create moodledata directory
sudo mkdir /var/www/moodledata
sudo chown -R apache:apache /var/www/moodledata
sudo chmod -R 755 /var/www/moodledata# Create Moodle virtual host
sudo nano /etc/httpd/conf.d/moodle.confAdd the following content:
<VirtualHost *:80>
DocumentRoot /var/www/moodle
<Directory /var/www/moodle>
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/moodle_error.log
CustomLog /var/log/httpd/moodle_access.log combined
</VirtualHost>sudo systemctl restart httpd# Edit PHP configuration
sudo nano /etc/php.iniUpdate these settings:
memory_limit = 256M
upload_max_filesize = 200M
post_max_size = 200M
max_execution_time = 300
max_input_vars = 5000
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT# Install development packages
sudo dnf install -y php-devel php-pear gcc libsodium-devel
# Install libsodium from source
cd /tmp
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.19-stable.tar.gz
tar -xzf libsodium-1.0.19-stable.tar.gz
cd libsodium-stable
./configure
make && make check
sudo make install
sudo ldconfig# Remove PHP 8.1
sudo dnf remove -y php8.1 php8.1-*
# Install PHP 8.2 with sodium
sudo dnf install -y php8.2 php8.2-sodium php8.2-cli php8.2-fpm php8.2-mysqlnd php8.2-xml php8.2-soap php8.2-intl php8.2-zip php8.2-gd php8.2-mbstring php8.2-opcache php8.2-pdo
# Copy PHP configuration
sudo cp /etc/php.ini.rpmsave /etc/php.ini
# Update max_input_vars
sudo sed -i 's/;max_input_vars = 1000/max_input_vars = 5000/' /etc/php.ini
# Start and enable services
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
sudo systemctl restart httpd# Check PHP version
php -v
# Check sodium extension
php -m | grep sodium
# Check max_input_vars
php -i | grep max_input_vars- Open browser β Navigate to
http://YOUR_PUBLIC_IP - Verify server checks - All should show "OK"
- Click "Continue"
- Database Host: localhost
- Database Name: moodledb
- Database User: moodleuser
- Database Password: Moodle2025!@#
- Database Port: 3306
- Tables Prefix: mdl_
- Username: admin (or your choice)
- Password: Strong password meeting requirements
- First Name: Admin
- Last Name: User
- Email: Your email address
- Full site name: Your LMS name
- Short name: LMS
- Timezone: Your local timezone
- Self registration: Disable (recommended)
- Click "Save changes"
- Skip registration (optional)
- Access Moodle Dashboard
- β Access Moodle dashboard
- β All server checks pass
- β Admin account works
- β Database connection successful
# Set up SSL/HTTPS (recommended)
# Configure firewall rules
# Set up automated backups
# Configure email settings# Enable OPcache
# Configure MySQL settings
# Set up caching
# Monitor system resourcesSolution: Follow Phase 4, Step 3 to install PHP 8.2 with sodium support
Solution: Update php.ini with max_input_vars = 5000
Solution: Check security group rules and ensure HTTP (80) is open
Solution: Verify database credentials and MySQL service status
- β PHP 8.2.29 with sodium extension
- β MySQL 8.0.43 database
- β Apache HTTP Server configured
- β All required PHP extensions installed
- β Proper file permissions set
- β Security settings configured
A fully functional Moodle 4.4.11 Learning Management System running on AWS EC2 with:
- Production-ready configuration
- Secure database setup
- Optimized PHP settings
- Complete admin access
- Ready for course creation and user management
For issues or questions:
- Check server logs:
/var/log/httpd/and/var/log/mysqld.log - Verify all services are running:
sudo systemctl status httpd php-fpm mysqld - Check PHP configuration:
php -i - Review Moodle documentation: https://docs.moodle.org/
π Congratulations! Your Moodle LMS is ready for production use!