Skip to content

Instantly share code, notes, and snippets.

@combs
Created May 16, 2019 15:42
Show Gist options
  • Save combs/aa0c422ee2aece8f6d55e38c86126976 to your computer and use it in GitHub Desktop.
Save combs/aa0c422ee2aece8f6d55e38c86126976 to your computer and use it in GitHub Desktop.
This script looks for previously installed apt packages for PHP extensions, and reinstalls them with a version you provide. E.G., php7.1-zip -> php7.3-zip
#!/bin/bash
if [ -z $1 ]
then
echo "Usage: $0 7.3 to install php7.3 modules"
exit
fi
echo "Fetching packages... Your sudo password may be required:"
packages=`sudo dpkg --get-selections | grep -v deinstall | grep php | awk '{{ print $1 }}' | sed -e 's:^php.\..[-]*::' | sort | uniq`
echo "About to install php $1 extensions: $packages"
echo "Ctrl+C to abort"
sleep 5
for arg in $packages
do sudo apt-get install -y php$1-$arg
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment