Skip to content

Instantly share code, notes, and snippets.

@floriankraemer
Last active May 3, 2024 17:52
Show Gist options
  • Save floriankraemer/2f43c69b30b89b887e4ac2292df54d67 to your computer and use it in GitHub Desktop.
Save floriankraemer/2f43c69b30b89b887e4ac2292df54d67 to your computer and use it in GitHub Desktop.
PHP installer script for Ubuntu
#!/usr/bin/env bash
# https://computingforgeeks.com/how-to-install-php-on-ubuntu/
phpVersions=('8.1')
modules=('zip' 'cli' 'fpm' 'bcmath' 'gd' 'xml' 'mbstring' 'xml' 'curl' 'pgsql' 'mysql' 'imagick' 'intl' 'amqp' 'intl' 'imap' 'opcache' 'redis', 'dom')
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