Skip to content

Instantly share code, notes, and snippets.

@tronsha
Last active October 13, 2023 00:13
Show Gist options
  • Save tronsha/b471dd6d73dc8ebae242 to your computer and use it in GitHub Desktop.
Save tronsha/b471dd6d73dc8ebae242 to your computer and use it in GitHub Desktop.
Install PHP7 to Ubuntu
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
apt-get update
apt-get install -y git-core autoconf bison libxml2-dev libbz2-dev libmcrypt-dev libcurl4-openssl-dev libltdl-dev libpng-dev libpspell-dev libreadline-dev make
mkdir -p /etc/php7/conf.d
mkdir -p /etc/php7/cli/conf.d
mkdir /usr/local/php7
cd /tmp
git clone https://github.com/php/php-src.git --depth=1
cd php-src
./buildconf
./configure --prefix=/usr/local/php7 --enable-bcmath --with-bz2 --enable-calendar --enable-exif --enable-dba --enable-ftp --with-gettext --with-gd --enable-mbstring --with-mcrypt --with-mhash --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --enable-pcntl --with-pspell --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-zlib --enable-zip --with-readline --with-curl --with-config-file-path=/etc/php7/cli --with-config-file-scan-dir=/etc/php7/cli/conf.d
make
make test
make install
@hvanmegen
Copy link

Please add root-permission check like @akeinhell stated 7 days ago:

if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi

Also, add the 'make' package to 'apt-get install' list of packages; I just installed a fresh 14.04 server, and that package was missing :)

@tronsha
Copy link
Author

tronsha commented Jan 8, 2016

thanks @akeinhell, I've added it

@tronsha
Copy link
Author

tronsha commented Jan 8, 2016

thanks @hvanmegen, I've added the make to 'apt-get install'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment