Skip to content

Instantly share code, notes, and snippets.

@christopher-hopper
Last active May 16, 2023 11:02
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save christopher-hopper/d3467ab87217dc1143f832ba7012c0f7 to your computer and use it in GitHub Desktop.
Save christopher-hopper/d3467ab87217dc1143f832ba7012c0f7 to your computer and use it in GitHub Desktop.
Install phpenv on Ubuntu 16.04 LTS (xenial)
#!/usr/bin/env bash
# vim: ai ts=2 sw=2 et sts=2 ft=sh
# Check OS.
if [[ ! "${OSTYPE}" =~ "^linux" ]] || [[ ! "$(lsb_release -c 2>/dev/null)" =~ "xenial" ]]; then
(>&2 echo "Error: This script is for Ubuntu 16.04 LTS (xenial) not '${OSTYPE}'.")
exit 1;
fi
sudo apt-get update
# Build dependencies.
sudo apt-get install -y build-essential git-core curl wget
sudo apt-get -y build-dep php-cli
sudo apt-get install -y libcurl4-openssl-dev libmcrypt-dev libreadline-dev libxslt1-dev libxml2-dev
# Installer for phpenv.
curl -L http://git.io/phpenv-installer | bash
# List available PHP builds to install.
phpenv install --list
# Install php70
phpenv install 7.0.27
# Install php71
phpenv install 7.1.13
# Install php72
phpenv install 7.2.1
for PHP_PATH in $HOME/.phpenv/versions/[0-9].[0-9].[0-9]*; do
PHP_VERSION=${PHP_PATH##*/};
unlink "${HOME}/.phpenv/versions/${PHP_VERSION%.*}" 2>/dev/null
ln -s "${PHP_PATH}" "${HOME}/.phpenv/versions/${PHP_VERSION%.*}" 2>/dev/null
done
phpenv rehash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment