Skip to content

Instantly share code, notes, and snippets.

@Aldo-f
Last active March 6, 2024 14:11
Show Gist options
  • Save Aldo-f/d274d0f938d553cdbb0bf32f1537ad15 to your computer and use it in GitHub Desktop.
Save Aldo-f/d274d0f938d553cdbb0bf32f1537ad15 to your computer and use it in GitHub Desktop.
install_php_modules.sh
#!/bin/bash
# Update package lists
sudo apt-get update
# Upgrade installed packages
sudo apt-get upgrade -y
# Fetch all installed PHP versions
php_versions=$(ls /etc/php)
echo "Installed PHP versions:"
echo "$php_versions"
# Check if a module argument is provided
if [ -z "$1" ]; then
read -p "Enter the PHP modules to install (comma-separated): " php_modules
else
php_modules=$1
fi
# Install PHP modules for each PHP version
for php_version in $php_versions; do
sudo apt-get install -y php$php_version-$php_modules
done
# Clean up package cache
sudo apt-get clean
# Remove unused packages
sudo apt autoremove -y
echo "PHP modules installation complete."
# Restart all Apaches
./restart_apaches.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment