Skip to content

Instantly share code, notes, and snippets.

@timothymarois
Last active November 9, 2019 18:34
Show Gist options
  • Save timothymarois/ece25a7a83b973ec6f8f12134433905c to your computer and use it in GitHub Desktop.
Save timothymarois/ece25a7a83b973ec6f8f12134433905c to your computer and use it in GitHub Desktop.
Remove PHP Versions
#!/usr/bin/env bash
# Upgrade an Amazon Linux EC2 to PHP 7.3
#
# Must be ran as sudo:
# sudo bash install-php73.sh
#
# Install Git
yum install -y git
# Install PHP 7.3 - Uncommon needs commented out. Uncomment what you need and add dependencies as needed.
yum install -y httpd24 mod24_ssl
yum install -y php73
# These are already installed by the php73 install:
# yum install -y php73-json
# yum install -y php73-common
# yum install -y php73-process
# yum install -y php73-cli
# yum install -y php73-xml
# Install the extras:
yum install -y php73-bcmath
yum install -y php73-imap
yum install -y php73-mbstring
yum install -y php73-mysqlnd
yum install -y php73-pdo
yum install -y php73-opcache
yum install -y php73-soap
yum install -y php73-gd
# Restart Apache.
service httpd restart
# Install Composer
curl -sS https://getcomposer.org/installer | sudo php
sudo mv composer.phar /usr/local/bin/composer
sudo ln -s /usr/local/bin/composer /usr/bin/composer
#!/usr/bin/env bash
# Upgrade an Amazon Linux EC2 to PHP 7.3
#
# Must be ran as sudo:
# sudo bash remove-php.sh
#
# We will remove instances of PHP matching:
remove=( php56 php70 php71 php72 php73 )
# Clean previous versions of PHP for determinism!
set +e
if [[ ! -z "$remove" ]]
then
for ver in "${remove[@]}"
do
modules=$( rpm -qa --queryformat "%{name}\n" | grep "$ver" )
if [[ ! -z "$modules" ]]
then
echo "Removing $ver"
for module in "${modules[@]}"
do
yum remove $module -y
done
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment