Installing PHP7 Beta 1 as php-fpm variant on a Ubuntu 14.04 LTS system.

After major parts of the PHP community were against releasing PHP6 as the successor of PHP5, the new official replacement of PHP5 will now be PHP7. A first beta version is now available and the final release is planned on October 2015. Because there are no official packages to be installed for Debian or Ubuntu at the moment, we’ll create a PHP 7 php-fpm module by compiling the beta 1 source code. That will also allow us to continue having PHP5 on our server as the main version but use PHP7 to test our projects for compatibility.

Update PHP 7.0.0: Installing the final PHP 7 as a php-fpm module on a Ubuntu 14.04 LTS system

For a first glimps of the new features and changes of PHP 7 I suggest reading the following article form the Zend Homepage: Coolest PHP 7 Features

1. Download

The most recent source code is available via the official Git Repository. Instead we will use the first Beta Version from the PHP Servers for now.

The source code was now downloaded and extracted and we changed into the new directory.

2. Configure the source code

We’ll need a lot of support packages to compile the code successfully. With the following commands all of the needed modules should be installed.

Now we can configure the source code.

Known issues during the configuration process

Error:

configure: error: Unable to locate gmp.h

Solution:

Create a symbolic link.

3. Compile

This will take some time. If make has finished without errors we’ll use checkinstall to create a Debian/Ubuntu package file that will contain all the new files we just created. That way we’ll also be able to remove the files again easily using a package manager of our choice.

checkinstall will ask for a package name, a maintaner and a description. As package name I would suggest using php7 to avoid conflicts with existing PHP installations. After that a .deb file will be created and also installed on our system.

The remove the changes again we can simply use:

4. First tests

The most simple test would be using the command line interface (CLI)

This should return version information like version numebr PHP 7.0.0beta1.  The next command will return data regarding the installed modules as well as configuration paramenters.

5. Using the php-fpm module with Apache and fastcgi

We’ll assume that the Apache webserver is installed an running. First we’ll install the fastcgi module and enable the action module.

Next step is to create config files for php-fpm and start the process.

With that we have created a www.conf file defining a process pool. We replaced the user and group values nobody with www-data and launched the php-fpm process. If the system already has a php-fpm module installed, for example PHP5, we should also change the port number in that file.

The only thing left is now to add the following line into a VirtualHost configuration of our choice.

Instead of  /var/www you have the use the real path to our DocumentRoot folder. Apache needs to be restarted for the changes to take effect.

Example Initscript for our new php-fpm server process

You might have to create the following folders manually /opt/php7/var /opt/php7/var/log and /opt/php7/var/run.

6. Use php-fpm with NginX

If your NginX server is already setup to work with a php-fpm process the following lines should be found in the configuration files:

In that case you should already have changed the TCP/IP port in the www.pool config file.  Just enter the new port instead of 9000 in the NginX configuration. After a reload the VirtualHost should then user PHP7 instead of PHP5.

Leave a Reply