Installing PHP7 on FreeBSD 10

Specifically, at time of writing, it’s PHP 7.0.3 on FreeBSD 10.1. Note that I would expect PHP7 to be officially available in FreeBSD and would hope that these instructions become redundant fast. Check for this with:

pkg search php70

At time of writing, the port we’re looking at is in development on Github here and it was announced on the FreeBSD ports mailing list here.

As you may gather from the above, PHP7 is available via ports only, not pkgng as yet. To install, proceed as follows:

portsnap fetch
cd /usr/ports
git clone https://github.com/miwi-fbsd/miwi-ports.git git-ports-php7
cd git-ports-php7
rsync -av ./* ../
portsnap fetch extract

Now remove your existing php:

pkg info | grep php
pkg remove ... ... ...

And install php70:

cd /usr/ports/lang/php70
make
make install

Follow this by installing any other PHP extensions you require. Note that in /usr/ports/Mk/bsd.php.mk I had to add the following at line 283 for database/php70-pdo_mysql to install:

_USE_PHP_VER70= ${_USE_PHP_ALL} phar sqlite3

Also note that Apache 2.4 is required. But who’s using 2.2 these days? Right..?