How to install PHP7 nightly on Linux

How to install PHP7 nightly on Linux

Deprecation

Without creating an article to install PHP7, I prefer to share with you this great post: How to Install PHP 7.0, Apache 2.4.17, & MySQL 5.6 on Ubuntu 15.10 & 14.

So, the following information in my article bellow are now deprecated and was only effective to the nightly version of PHP7.

Preamble

1sudo nano /etc/apt/sources.list
2deb http://archive.ubuntu.com/ubuntu jessie main
3aptitude update

Using early access repo

Add Zends PHP7 early access repo:

1echo "deb http://repos.zend.com/zend-server/early-access/php7/repos ubuntu/" >> /etc/apt/sources.list

To install PHP7 nighly build:

1apt-get update && apt-get install php7-nightly

Installing Apache 2.4

1aptitude install apache2 apache2-mpm-worker libapache2-mod-fastcgi

Then create the file /etc/apache2/conf-available/php7-fpm.conf with the contents:

1<IfModule mod_fastcgi.c>
2    AddHandler php7-fcgi .php
3    Action php7-fcgi /php7-fcgi
4    Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
5    FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php7-fpm.sock -pass-header Authorization
6</IfModule>

Then enable the new mods and config:

1a2enmod actions fastcgi alias
2a2enconf php7-fpm
3a2dismod mpm_event
4a2enmod mpm_prefork
5service apache2 reload

Install of MySQL

1aptitude install mysql-server mysql-client

Build and configure PHP7

To get, build and install PHP7 from sources, you will need some tools to be installed in your linux. Use the next command to install the needed tools:

1aptitude install git make autoconf build-essential libt1-dev libgmp-dev bison re2c libxml2-dev libcurl4-openssl-dev libssl-dev libsslcommon2-dev libbz2-dev libjpeg-dev libfreetype6-dev libmcrypt-dev libmysqlclient-dev libaspell-dev

Create a temporary directory:

1mkdir ~/tmp
2cd ~/tmp

Clone sources from git repository:

1git clone https://git.php.net/repository/php-src.git

You can now build and configure your env

1cd php-src
2./buildconf
3./configure \
4    --prefix=/usr/local/php7 \
5    --with-config-file-path=/usr/local/etc/php7 \
6    --localstatedir=/usr/local/var \
7    --sysconfdir=/usr/local/etc/php7 \
8    --enable-mbstring \
9    --enable-zip \
10    --enable-bcmath \
11    --enable-pcntl \
12    --enable-ftp \
13    --enable-exif \
14    --enable-calendar \
15    --enable-sysvmsg \
16    --enable-sysvsem \
17    --enable-sysvshm \
18    --enable-wddx \
19    --with-curl \
20    --with-mcrypt \
21    --with-iconv \
22    --with-gmp \
23    --with-pspell \
24    --with-gd \
25    --with-jpeg-dir=/usr \
26    --with-png-dir=/usr \
27    --with-zlib-dir=/usr \
28    --with-xpm-dir=/usr \
29    --with-freetype-dir=/usr \
30    --with-t1lib=/usr \
31    --enable-gd-native-ttf \
32    --enable-gd-jis-conv \
33    --with-openssl \
34    --with-mysql=/usr \
35    --with-pdo-mysql=/usr \
36    --with-pgsql=/usr \
37    --with-pdo-pgsql=/usr \
38    --with-firebird=/usr \
39    --with-pdo-firebird=/usr \
40    --with-pdo-odbc=unixODBC,/usr/ \
41    --with-oci8=instantclient,/usr/lib/oracle/12.1/client64/lib \
42    --with-pdo-oci=instantclient,/usr,12.1 \
43    --with-interbase=/usr \
44    --with-gettext=/usr \
45    --with-zlib=/usr \
46    --with-bz2=/usr \
47    --with-recode=/usr \
48    --with-mysqli=/usr/bin/mysql_config

You can now make and install sources

1make
2make test
3sudo make install

We now need to create a symlink:

1sudo ln -sf /usr/local/php7/bin/php /usr/bin/php

add to /etc/apache2/sites-enabled/000-default.conf or other vhost conf file:

1AddType application/x-httpd-php .php .phtml

php.ini

1cd /usr/local/etc/php7
2sudo nano php.ini

paste the code:

1max_execution_time=600
2memory_limit=128M
3error_reporting=1
4display_errors=1
5log_errors=1
6user_ini.filename=
7realpath_cache_size=2M
8cgi.check_shebang_line=0
9
10zend_extension=opcache.so
11opcache.enable_cli=1
12opcache.save_comments=1
13opcache.fast_shutdown=1
14opcache.validate_timestamps=1
15opcache.revalidate_freq=60
16opcache.use_cwd=1
17opcache.max_accelerated_files=100000
18opcache.max_wasted_percentage=5
19opcache.memory_consumption=128
20opcache.consistency_checks=0

Common errors

Unable to locate gmp.h

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

libfbclient, libgds or libib_util not found!

1aptitude install firebird2.5-dev

Cannot find header file(s) for pdo_odbc

1aptitude install unixodbc-dev unixodbc-bin unixodbc

Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

1aptitude install libpq-dev

Built with Next.js and Joy-UI, deployed on Vercel.

Designed and coded with ♥ in Montreal with WebStorm.

All text is set in the Nunito typeface.

© 2013-2024 All rights reserved.