Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.