Running PHP7-FPM Nightly Build on Ubuntu 14.04

As I’m writing this, the calendar shows April 14 2015. According to the PHP 7.0 timeline, it has a projected release date of November 2015. But if you want to try it out (to check out the speed), you can already do so.


UPDATE: PHP 7 stable was released December 3, 2015.
You might want to use a stable version instead of nightlies,
so head over to How to upgrade to PHP 7 on Ubuntu.


This guide assumes you already know how to setup PHP5-FPM with your web server. You might want to setup that first and make sure it is running fine with your web server of choice.

Oh, and all commands are executed as root. Use sudo if you like to.

First of all, head on over to the PHP7 Nightly Builds page at Zend and download the ZIP for DEB.

$ wget http://repos.zend.com/zend-server/early-access/php7/php-7.0-latest-DEB-x86_64.tar.gz

(The URL may or may not change, so check the above mentioned page first).

Zend also provides an installation guide for Ubuntu. It is missing documentation for installing as FPM, but we can at least use it as a starting point.

Install the required dependencies according to the Zend install guide mentioned (again, check the Zend page first):

$ apt-get update && apt-get install -y \
libcurl4-openssl-dev \
libmcrypt-dev \
libxml2-dev \
libjpeg-dev \
libfreetype6-dev \
libmysqlclient-dev \
libt1-dev \
libgmp-dev \
libpspell-dev \
libicu-dev \
librecode-dev

Then, unpack the archive. Note that the following command will unpack to /usr/local/php7 – Also note that the command on the Zend page uses an incorrect file name:

$ tar xzPf php-7*.tar.gz

Now you need to create your php-fpm.conf (use /usr/local/php7/etc/php-fpm.conf for your sanity). Use this as a starting point and adjust to your liking:

[global]
pid = /run/php7-fpm.pid
error_log = /var/log/php7-fpm.log

[www]
user = nginx
group = nginx

listen = 127.0.0.1:9000

pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 6

Make sure the listen config does not collide with your php5-fpm config. Change port or socket file name if needed.

Next, you need the System V init script in /etc/init.d/php7-fpm. I took the php5-fpm script from Ondřej Surý as a basis and just fixed the paths to php7-fpm. Feel free to download it here and make it executable:

$ wget -O /etc/init.d/php7-fpm "https://gist.github.com/bjornjohansen/bd1f0a39fd41c7dfeb3a/raw/f0312ec54d1be4a8f6f3e708e46ee34d44ef4657/etc%20inid.d%20php7-fpm"
$ chmod a+x /etc/init.d/php7-fpm

Then you need the init script in /etc/init/php7-fpm.conf. This one is also just an adaptation of Ondřej Surý’s script. Download from here.

$ wget -O /etc/init/php7-fpm.conf "https://gist.github.com/bjornjohansen/9555c056a7e8d1b1947d/raw/15920fa2f447358fdd1c79eecd75a53aaaec76f9/etc%20init%20php7-fpm"

You also need the checkconf script. Create the file /usr/local/lib/php7-fpm-checkconf and put this in it:

#!/bin/sh
set -e
errors=$(/usr/local/php7/sbin/php-fpm --fpm-config /usr/local/php7/etc/php-fpm.conf -t 2>&1 | grep "\[ERROR\]" || true);
if [ -n "$errors" ]; then
    echo "Please fix your configuration file…"
    echo $errors
    exit 1
fi
exit 0

Make it executable:

$ chmod a+x /usr/local/lib/php7-fpm-checkconf

Make sure php7-fpm starts when your system boots:

$ update-rc.d php7-fpm defaults

Start php7-fpm

$ service php7-fpm start

Have fun!

7 Comments

  1. Issue in your scripts!

    Manually typing everything you shown on this tutorial = Fail

    Copy and Paste every piece of code = Fail

    Copy & paste plus 1 hour debug = Works
    $ wget -O /etc/init/php7-fpm “https://gist.github.com/bjornjohansen/9555c056a7e8d1b1947d/raw/15920fa2f447358fdd1c79eecd75a53aaaec76f9/etc%20init%20php7-fpm”

    This snippet has an error or atleast using ubuntu 14.04 i got it working by moving the file /etc/init/php7-fpm to /etc/init/php7-fpm.conf

    Works properly now.

        1. Your setup is the standard one. I stand corrected, and have updated the post.
          Thank you!

  2. It’s in RC 4 release is their any different changes to install steps .
    and have you test WP is completely compatible with PHP7 .

    1. Zend publishes binaries of nightlies in both RPM and APT repositories now. You don’t have to compile nightlies of PHP7 yourself anymore: http://php7.zend.com/repo.php
      If you want RC4 specifically, instead of nightlies, you can download the source from here, and compile it yourself: https://downloads.php.net/~ab/

      WordPress is 100% compatible with PHP7 and will officially support it from the day PHP7 is released. This is not necessarily true for the plugins and themes you are using.

Comments are closed.