Skip to content

Instantly share code, notes, and snippets.

@burzum
Last active January 6, 2021 09:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burzum/75693e7812ce7894e3b83095199b80c2 to your computer and use it in GitHub Desktop.
Save burzum/75693e7812ce7894e3b83095199b80c2 to your computer and use it in GitHub Desktop.
Install php versions and modules automatically on Ubuntu
#!/usr/bin/env bash
# https://computingforgeeks.com/how-to-install-php-on-ubuntu/
phpVersions=('7.2' '7.3' '7.4')
modules=('cli' 'fpm' 'bcmath' 'gd' 'xml' 'mbstring' 'xml' 'curl' 'pgsql' 'imagick' 'intl' 'amqp' 'intl' 'imap' 'opcache')
sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
for phpVersion in "${phpVersions[@]}"
do
moduleString=""
for module in "${modules[@]}"
do :
moduleString="${moduleString} php${phpVersion=""}-${module}"
done
sudo apt -y install 'php'$phpVersion
echo 'Installing modules...'
sudo apt -y install $moduleString
done
sudo update-alternatives --config php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment