[Moodle Migration][Phase 3] Dual PHP-FPM

Context / intent

  • Target runtime for current site: PHP 8.0 (Moodle 4.0.9).
  • Prepare PHP 8.2 for the later 4.2 → 5.1 hop.
  • Web: Nginx, DB: MariaDB 11.4 LTS, OS: Ubuntu 24.04 LTS.

Process

3.1 Add PHP PPA (for side-by-side versions)

sudo apt update
sudo apt -y install software-properties-common
sudo add-apt-repository -y ppa:ondrej/php
sudo apt update

Result: PPA added successfully.

3.2 Install PHP 8.0 + extensions

sudo apt -y install \
  php8.0-fpm php8.0-cli php8.0-mysql php8.0-xml php8.0-mbstring \
  php8.0-curl php8.0-zip php8.0-gd php8.0-intl php8.0-soap \
  php-redis php-apcu

Notes / constraints met while doing this:

  • php8.0-exif and php8.0-sodium do not exist here. EXIF is in php8.0-common; Sodium is built-in.
  • php-redis and php-apcu are unversioned.

3.3 Install PHP 8.2 (idle, for later)

sudo apt -y install \
  php8.2-fpm php8.2-cli php8.2-mysql php8.2-xml php8.2-mbstring \
  php8.2-curl php8.2-zip php8.2-gd php8.2-intl php8.2-soap \
  php-redis php-apcu

3.4 Enable services + minimal INI for 8.0

sudo systemctl enable --now php8.0-fpm php8.2-fpm

sudo tee /etc/php/8.0/fpm/conf.d/50-moodle.ini >/dev/null <<'EOF'
memory_limit = 512M
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 300
opcache.enable=1
opcache.jit=0
EOF

sudo systemctl restart php8.0-fpm

3.5 Wire Nginx → PHP 8.0 (socket)

  • In the site config later, fastcgi_pass unix:/run/php/php8.0-fpm.sock; is used.
  • Switch plan for upgrade day: change that to php8.2-fpm.sock and reload Nginx.

State at end of Phase 3

  • Both FPM pools running; Nginx will use 8.0.
  • Ready to restore Moodle.