Skip to content

Instantly share code, notes, and snippets.

@friedemannsommer
Last active July 27, 2016 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save friedemannsommer/e5e1aaa0ee7945fa6284 to your computer and use it in GitHub Desktop.
Save friedemannsommer/e5e1aaa0ee7945fa6284 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Some help from the various places like these.
# http://www.zimuel.it/install-php-7/
# http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu
# https://gist.github.com/m1st0/1c41b8d0eb42169ce71a
sudo apt-get update
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password development'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password development'
sudo apt-get install libldap2-dev \
libldap-2.4-2 \
libtool \
libzip-dev \
lbzip2 \
libxml2-dev \
bzip2 \
re2c \
libbz2-dev \
apache2-dev \
libjpeg-dev \
libxpm-dev \
libxpm-dev \
libgmp-dev \
libgmp3-dev \
libmcrypt-dev \
libmysqlclient-dev \
mysql-server \
mysql-common \
libpspell-dev \
librecode-dev
sudo ln -sf /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so
sudo ln -sf /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so
sudo ln -sf /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
# pull git repo
git clone https://github.com/php/php-src
cd php-src
git checkout PHP-7.1
# fix configure issues.
./buildconf
# compile options
./configure --prefix="/usr/local/php7" \
--with-config-file-path="/etc/php7/apache2" \
--with-config-file-scan-dir="/etc/php7/apache2/conf.d" \
--disable-all \
--enable-bcmath \
--enable-pcntl \
--enable-ftp \
--enable-calendar \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--enable-intl \
--with-iconv \
--with-gmp \
--with-pspell \
--with-jpeg-dir="/usr" \
--with-png-dir="/usr" \
--with-zlib-dir="/usr" \
--with-xpm-dir="/usr" \
--with-freetype-dir="/usr" \
--with-t1lib="/usr" \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-openssl \
--with-pdo-mysql="/usr" \
--with-gettext="/usr" \
--with-zlib="/usr" \
--with-bz2 \
--with-mysqli="/usr/bin/mysql_config" \
--with-ldap \
--with-openssl \
--with-gd \
--enable-gd-native-ttf \
--enable-intl \
--enable-mbstring \
--with-mcrypt \
--with-mysqli="mysqlnd" \
--with-zlib \
--with-bz2 \
--enable-exif \
--with-pdo-mysql="mysqlnd" \
--with-libedit \
--enable-zip \
--enable-pdo \
--enable-sockets \
--with-pcre-regex \
--with-tsrm-pthreads \
--enable-fpm \
--with-fpm-user="www-data" \
--with-fpm-group="www-data" \
--enable-cli \
--enable-maintainer-zts \
--enable-opcache \
--enable-simplexml \
--enable-json \
--enable-hash \
--enable-session \
--enable-xml \
--enable-wddx \
--with-xsl \
--with-enchant \
--with-gettext \
--with-curl \
--with-readline
# Cleanup for previous failures.
sudo make clean
# Using as many threads as possible.
sudo make -j `cat /proc/cpuinfo | grep processor | wc -l`
# Install it accoridng to the configured path.
sudo make install
# It's own make script said to do this, but it didn't do much on my system.
libtool --finish ./libs
# Work on non-threaded version as compiled for now.
sudo a2dismod mpm_worker
sudo a2enmod mpm_event
# Since it is built with axps2, it sets things up correctly.
sudo a2enmod php7
# Restart Apache if all went well.
sudo systemctl restart apache2
# Update the paths on the system according to Ubuntu. Can be later removed and switched back.
sudo update-alternatives --install /usr/bin/php php /usr/local/php7/bin/php 50 \
--slave /usr/share/man/man1/php.1.gz php.1.gz \
/usr/local/php7/php/man/man1/php.1
# ask user which version to use
sudo update-alternatives --config php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment