Install PHP 7.0

How to compile PHP 7 on Linux Posted by on February 05, 2015

Update: PHP 7.0.0 has been released 3th Dec. 2015, you can install from
Update: If you are using Ubuntu 15.04, you can have a look at this script by Maulik Mistry.

I just installed PHP 7.0.0-dev (based on PHPNG) on my GNU/Linux box (Ubuntu 14.04) and I found some errors during the procedure. I decided to write this note to help people using the same Ubuntu environment.

Before to start I would like to remind that PHP 7 is still in development and SHOULD NOT BE USED in production environments. I installed to try and experiment the new features of the language. The first stable release of PHP 7 is scheduled by the end of the year, with a projected release date of November 2015.

To install PHP 7 we need to clone the php-src repository, configure and compile. Let's create a php7 folder in the home directory and clone the project:

mkdir $HOME/php7
cd $HOME/php7
git clone

After that, we need to prepare and configure the compiler. We need to execute the following commands:

cd php-src
./configure \
    --prefix=$HOME/php7/usr \
    --with-config-file-path=$HOME/php7/usr/etc \
    --enable-mbstring \
    --enable-zip \
    --enable-bcmath \
    --enable-pcntl \
    --enable-ftp \
    --enable-exif \
    --enable-calendar \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-wddx \
    --with-curl \
    --with-mcrypt \
    --with-iconv \
    --with-gmp \
    --with-pspell \
    --with-gd \
    --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-mysql=/usr \
    --with-pdo-mysql=/usr \
    --with-gettext=/usr \
    --with-zlib=/usr \
    --with-bz2=/usr \
    --with-recode=/usr \

During the execution of configure command, I found a couple of errors.

Error: Your t1lib distribution is not installed correctly.

I fixed using:

sudo apt-get install libt1-dev

Error: Unable to locate gmp.h

I tried to install the libgmp-dev library:

sudo apt-get install libgmp-dev

but the library was already installed, so I search for it:

locate gm.h

and I found it on /usr/include/x86_64-linux-gnu/gmp.h (I'm using a 64bit version). I tried to symlink it to /usr/include/gmp.h (the default location for include):

ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h

and finally the configure execution was successful. If you find other errors on your environment, I suggest to read this post by Maciej Zgadzaj, where he reported a list of possible errors and solutions for Ubuntu systems.

Now it's time to compile PHP 7 with the following commands:

make install

The first command compile the PHP. I took about 9 minutes to compile PHP 7 on my computer (Intel i5-2500 at 3.3Ghz). The second command install the PHP modules and configuration in $HOME/php7/usr folder.

We have almost done the installation, we just need to create the php.ini file in the $HOME/php7/usr/etc folder. We can easily create it using vi with the following commands:

mkdir $HOME/php7/usr/etc
vi $HOME/php7/usr/etc/php.ini

We can use the following content for the php.ini:


And finally we can test PHP using the command line interface (CLI):

$HOME/php7/php-src/sapi/cli/php -v

You will get a result like this:

PHP 7.0.0-dev (cli) (built: xxx)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies

If you want to learn about the new features of PHP 7 I suggest to read the following resources: