Cleaning Up Moosh and PHP Dependencies on Moodle Servers

Why Removing a PPA-Installed Moosh Requires Care

Moosh is commonly installed via the third-party PPA:

ppa:zabuch/ppa

This repository often introduces non-default PHP versions (e.g. 8.3 or 8.4) and related extensions. On production systems, those packages may:

  • Replace Ubuntu’s default PHP version
  • Change CLI PHP independently of FPM
  • Affect Apache or Nginx PHP handlers
  • Introduce dependency conflicts during system upgrades

Removing Moosh incorrectly can leave your server in a mixed package state.

This guide covers clean removal, package downgrade, and post-removal validation.

Applies to:

  • Ubuntu 22.04 LTS
  • Ubuntu 24.04 LTS

Assess Current Package State

Before changing anything, confirm what is installed from the PPA.

List Moosh and PHP packages

dpkg -l | grep -E "moosh|php8\.[34]"

Check package origin

apt-cache policy moosh
apt-cache policy php8.3

Look for:

500 http://ppa.launchpad.net/zabuch/ppa

This confirms packages are sourced from the PPA.

Identify reverse dependencies

Before removing PHP versions:

apt-cache rdepends php8.3

This shows what depends on that package.

Always check reverse dependencies before purging PHP. Removing the wrong version can break active FPM pools or Apache modules.

ppa-purge does two important things:

  1. Removes packages installed from the PPA
  2. Downgrades them back to official Ubuntu repository versions

Install if needed:

sudo apt-get update
sudo apt-get install ppa-purge -y

Run purge:

sudo ppa-purge ppa:zabuch/ppa

This:

  • Removes Moosh
  • Downgrades PHP packages
  • Cleans repository configuration

Manual Removal (If ppa-purge Is Not Available)

If you must remove manually, follow this order carefully.

1. Remove Moosh Only

sudo apt-get remove --purge moosh -y

2. Remove the PPA Repository

sudo add-apt-repository --remove ppa:zabuch/ppa -y
sudo apt-get update

3. Reinstall Ubuntu Default PHP (If Required)

Check Ubuntu’s default PHP version:

apt-cache policy php

Reinstall:

sudo apt-get install --reinstall php php-cli php-fpm -y

4. Clean Residual Packages

sudo apt-get autoremove --purge -y
sudo apt-get clean

Post-Removal Validation

Do not assume success after package removal.

1. Confirm Moosh Is Removed

which moosh
dpkg -l | grep moosh

Both should return no results.

2. Confirm PPA Files Are Gone

ls /etc/apt/sources.list.d/ | grep zabuch

If files remain:

sudo rm /etc/apt/sources.list.d/zabuch-ubuntu-ppa-*.list
sudo apt-get update

3. Validate PHP Across All Contexts

Check CLI:

php -v

Check FPM service:

systemctl status php8.1-fpm

Check active sockets:

ls /run/php/

If using Apache:

apachectl -M | grep php

If using Nginx:

Inspect your site config:

fastcgi_pass unix:/run/php/php8.1-fpm.sock;

Ensure the socket matches the installed PHP version.

CLI PHP, FPM PHP, and web server PHP can differ. Validate all three to avoid silent breakage.

Handling Common Failure Scenarios

Web Application Returns 502

Likely cause:

  • FPM service removed or wrong socket configured

Fix:

sudo systemctl restart php8.1-fpm
sudo systemctl restart nginx

Broken Dependencies After Removal

Repair package state:

sudo apt-get -f install
sudo dpkg --configure -a

System Still Pulling from PPA

Confirm no PPA entries remain:

grep -R "zabuch" /etc/apt/

Remove any remaining references and run:

sudo apt-get update

When Not to Remove the PPA

Do not remove the PPA if:

  • You intentionally rely on PHP versions not available in Ubuntu repositories
  • Other applications depend on packages exclusively provided by that PPA
  • You are mid-upgrade between Ubuntu releases

In those cases, isolate Moosh removal only.

Further thoughts…

Removing Moosh is straightforward. Removing a PPA that alters your PHP stack is not.

Before purging:

  • Check package origin
  • Inspect reverse dependencies
  • Confirm active PHP services
  • Validate web server configuration
  • Test application endpoints after changes

On production systems, take a snapshot or backup first. A 5-minute precaution is cheaper than debugging a broken PHP-FPM stack under pressure.