Compile PHP7 RC7 from scratch for use with nginx, MySQL and PostgreSQL

As the PHP Community decided to publish another PHP release candidate people are getting more and more excited about the official release of PHP7. The release first was scheduled for 12th November but has been shifted to 26th November if no new critical Bugs are found in the newly released RC7.

As the benefits of PHP7 are huge I decided to compile the latest version of PHP7 by hand and install on my Ubuntu 14.04 based development server.

After a small search I found a Gist by jaswrks with complete bash commands for compiling php-cli and php-fpm using PHP7 RC2.

I’m using nginx as webserver and PostgreSQL / MySQL. As I’m running Moodle 3.0rc3 on my development server I had to enable some more PHP modules than

jaswrks and enabled PDO for MySQL and PostgreSQL.

So I forked his Gist and modified it to my needs. The updated version is available here and pasted below.

A tutorial showing how to activate php-fpm in nginx is available here.

#!/usr/bin/env bash

sudo -i;

apt-get update;

apt-get install --yes \
git \
bison \
autoconf \
libltdl-dev \
libbz2-dev \
libxml2-dev \
libxslt1-dev \
libpspell-dev \
libenchant-dev \
libmcrypt-dev \
libpng-dev \
libjpeg8-dev \
libfreetype6-dev \
libpg-dev \
libmysqlclient-dev \
libicu-dev \

mkdir --parents /usr/local/php7;
mkdir --parents /etc/php7/conf.d;
mkdir --parents /etc/php7/cli/conf.d;
mkdir --parents /etc/php7/fpm/conf.d;
mkdir --parents --mode=777 /var/log/php7;

git clone /usr/local/src/php7 --branch=php-7.0.0RC7 --depth=1;

cd /usr/local/src/php7;
./buildconf --force;

php_configure_args=" \
--prefix=/usr/local/php7 \
--with-bz2 \
--with-zlib \
--enable-zip \
--with-mcrypt \
--with-openssl \
--with-curl \
--enable-ftp \
--with-pgsql \
--with-pdo-pgsql \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-sockets \
--enable-pcntl \
--with-pspell \
--with-enchant \
--with-gettext \
--with-gd \
--enable-exif \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-xsl \
--enable-bcmath \
--enable-mbstring \
--enable-calendar \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-soap \
--with-xmlrpc \
--enable-intl \
./configure $php_configure_args \
--with-config-file-path=/etc/php7/cli \
make -j 4 && make install && make clean;

./configure $php_configure_args \
--disable-cli --enable-fpm \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--with-config-file-path=/etc/php7/fpm \
make -j 4 && make install && make clean;

ln --symbolic /usr/local/php7/bin/php /usr/bin/php;
ln --symbolic /usr/local/php7/sbin/php-fpm /usr/sbin/php-fpm;

echo '' > /etc/php7/conf.d/opcache.ini;
ln --symbolic /etc/php7/conf.d/opcache.ini /etc/php7/cli/conf.d/opcache.ini;
ln --symbolic /etc/php7/conf.d/opcache.ini /etc/php7/fpm/conf.d/opcache.ini;

Published by

Matthias Wirtz

“First, solve the problem. Then, write the code.” - John Johnson