Compiling PHP 5.7 on Ubuntu

After noticing the big performance increase of PHP 5.7 Next Generation, I wanted to try it out myself. After 30 seconds my Digital Ocean VPS was ready to use:

Install some basic dependencies needed for successful compiling

aptitude install autoconf automake libtool re2c flex make libxml2-dev libssl-dev libbz2-dev libcurl3-dev libdb5.1-dev libjpeg-dev libpng-dev libXpm-dev libfreetype6-dev libt1-dev libgmp3-dev libc-client-dev libldap2-dev libmcrypt-dev libmhash-dev freetds-dev libz-dev libmysqlclient15-dev ncurses-dev libpcre3-dev unixODBC-dev libsqlite-dev libaspell-dev libreadline6-dev librecode-dev libsnmp-dev libtidy-dev libxslt-dev libt1-dev openssl openssl-dev libssl libssl-dev libxml2 libxml2-dev libpspell-dev libicu-dev

Compile Bison 2.4

wget http://ftp.gnu.org/gnu/bison/bison-2.4.tar.gz
tar -xzf bison-2.4.tar.gz
cd bison-2.4
./configure
make && make install
cd ../

Compile PHP 5.7

git clone https://git.php.net/repository/php-src.git
cd php-src
git branch phpng origin/phpng
git checkout phpng

./buildconf
./configure \
   --with-config-file-path=/etc \
   --enable-mbstring \
   --enable-zip \
   --enable-bcmath \
   --enable-pcntl \
   --enable-ftp \
   --enable-intl \
   --enable-exif \
   --enable-calendar \
   --enable-sysvmsg \
   --enable-sysvsem \
   --enable-sysvshm \
   --enable-wddx \
   --with-curl \
   --with-mcrypt \
   --with-iconv \
   --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 \
   --with-mysqli=/usr/bin/mysql_config

make
make install

Creating php.ini

php.ini should be created in /etc. I got some weird segfaults when opcode caching was enabled, so I commented it:

max_execution_time=600
memory_limit=128M

display_errors=1
log_errors=1
error_reporting = E_ALL & ~E_DEPRECATED
user_ini.filename=
realpath_cache_size=2M
cgi.check_shebang_line=0
error_log = syslog

#zend_extension=opcache.so
#opcache.enable_cli=1
#opcache.save_comments=0
#opcache.fast_shutdown=1
#opcache.validate_timestamps=1
#opcache.revalidate_freq=60
#opcache.use_cwd=1
#opcache.max_accelerated_files=100000
#opcache.max_wasted_percentage=5
#opcache.memory_consumption=128
#opcache.consistency_checks=0
#opcache.save_comments=1

date.timezone = Europe/Brussels
date.default_latitude = 50.877369
date.default_longitude = 4.684167

To start the pool I created a quick and dirty bash file: fpm.sh. This can be run in the background using nohup ./fpm.sh &and starts a pool of 4 children. The fcgi-socket is located at /tmp/fcgi-php

#!/bin/bash
PHP_FCGI_CHILDREN=4 PHP_FCGI_MAX_REQUESTS=0 php-cgi -b /tmp/fcgi-php

The result:

PHP 5.7.0-dev (cli) (built: Jul 17 2014 04:14:19)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.7.0-dev, Copyright (c) 1998-2014 Zend Technologies
comments powered by Disqus