Simon Bennett

Web Developer

Web Development Simon Bennett

PHP 7.1 Alpha is out, whats new and how to test

Posted: June 13, 2016

PHP 7.1 is out with some bug fixes and new features.

The most notable changes are

 

You may want to test your code against 7.1 which is always a good idea, I have provided a simple bash script for compiling php on ubuntu, do not run this on a production system!

#!/usr/bin/env bash
apt-get update
apt-get install -y bison autoconf build-essential pkg-config git-core libltdl-dev libbz2-dev libxml2-dev libxslt1-dev libssl-dev libicu-dev libpspell-dev libenchant-dev libmcrypt-dev libpng-dev libjpeg8-dev libfreetype6-dev libmysqlclient-dev libreadline-dev libcurl4-openssl-dev
apt-get -yq install bzip2 openssl libxml2 libxml2-dev gcc make autoconf htop sudo git dstat

apt-get install -yq --force-yes \
libldap2-dev \
libldap-2.4-2 \
libzip-dev \
lbzip2 \
libxml2-dev \
bzip2 \
re2c \
libbz2-dev \
libjpeg-dev \
libxpm-dev \
libxpm-dev \
libgmp-dev \
libgmp3-dev \
libmcrypt-dev \
libmysqlclient-dev \
mysql-common \
libpspell-dev \
librecode-dev \
curl \
libcurl4-gnutls-dev \
libldap2-dev \
libldap-2.4-2 \
libtool \
libzip-dev \
lbzip2 \
libxml2-dev \
bzip2 \
re2c \
libbz2-dev \
apache2-dev \
libjpeg-dev \
libxpm-dev \
libxpm-dev \
libgmp-dev \
libgmp3-dev \
libmcrypt-dev \
libmysqlclient-dev \
mysql-common \
libpspell-dev \
librecode-dev \
libjpeg-dev \
libpng12-dev \
libxpm-dev \
libfreetype6-dev \
libxpm-dev \
libicu-dev \
libenchant-dev \
libxslt-dev

mkdir -p /etc/php7
mkdir -p /etc/php7/cli
mkdir -p /etc/php7/etc

cd ~/
wget https://downloads.php.net/~krakjoe/php-7.1.0alpha1.tar.bz2
tar xvfj php-7.1.0alpha1.tar.bz2
cd php*

./buildconf --force
CONFIGURE_STRING="--prefix=/etc/php7 --with-bz2 --enable-fastcgi --with-zlib --enable-zip --enable-soap --enable-intl --with-mcrypt --with-openssl --with-readline --with-curl --enable-ftp --enable-mysqlnd --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-simplexml --enable-json --enable-hash --enable-session --enable-xml --enable-wddx --enable-opcache --with-pcre-regex --with-config-file-path=/etc/php7/cli --with-config-file-scan-dir=/etc/php7/etc --enable-cli --enable-debug --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data"
./configure $CONFIGURE_STRING

sudo make -j `cat /proc/cpuinfo | grep processor | wc -l`
make install
chmod o+x /etc/php7/bin/phpize
chmod o+x /etc/php7/bin/php-config

cd ext/pthreads*
#git checkout v3.1.7dev
/etc/php7/bin/phpize
./configure --prefix='/etc/php7' --with-libdir='/lib/x86_64-linux-gnu' --enable-pthreads=shared --with-php-config='/etc/php7/bin/php-config'
make && make install

cd ../../
cp -r php.ini-production /etc/php7/cli/php.ini

sed -i 's/;date.timezone =.*/date.timezone = Europe\/London/' /etc/php7/cli/php.ini

cp /etc/php7/etc/php-fpm.conf.default /etc/php7/etc/php-fpm.conf
cp /etc/php7/etc/php-fpm.d/www.conf.default /etc/php7/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm

sed -i 's/Provides: php-fpm/Provides: php7-fpm/' /etc/init.d/php7-fpm
sed -i 's#^php_fpm_BIN=.*#php_fpm_BIN=/usr/sbin/php7-fpm#' /etc/init.d/php7-fpm
sed -i 's#^php_fpm_CONF=.*#php_fpm_CONF=/etc/php7/etc/php-fpm.conf#' /etc/init.d/php7-fpm
sed -i 's#^php_fpm_PID=.*#php_fpm_PID=/var/run/php7-fpm.pid#' /etc/init.d/php7-fpm

cp php.ini-production /etc/php7/cli/php-cli.ini
echo "zend_extension=opcache.so" >> /etc/php7/cli/php.ini

ln --symbolic /etc/php7/bin/php /usr/bin/php
ln --symbolic /etc/php7/bin/php-cgi /usr/bin/php-cgi

ln --symbolic /etc/php7/sbin/php-fpm /usr/sbin/php7-fpm

chmod +x /etc/init.d/php7-fpm
update-rc.d php7-fpm defaults
Written By Simon Bennett (find me on )

Leave a Reply

Your email address will not be published. Required fields are marked *