How to install phpng aka php7 on FreeBSD 10

FreeBSD Mug

Update : I already try official PHP 7 and wrote it here (using git) and there (using tar.gz file)

FreeBSD Mug by wsinetworks

I just curious about php next generation aka phpng aka php7 . After a few times fail with hhvm ( FreeBSD hhvm and DragonFlyBSD hhvm) I think I need to test something different for my lab experiment 🙂

The choice came to phpng and with the help from Vultr I can cure my curiosity in fast deployment. Well,

I use this configuration :

VPS location : Germany (Frankfurt), Europe.

freebsd_vps_europe1

FreeBSD version : FreeBSD 10 64 bit

freebsd_vps_europe2

Specs : 1 cpu, 768 MB memory, 15 GB storage and 1000 GB transfer.

freebsd_europe_vps_4

Great, Hit ‘Place Order’ button and I can test it.

Steps :

Most of step taken from php.net wiki of phpng.

1. Log in to server using ssh

freebsd_europe_vps5

In case of password, you can refer to server info tab and look for ‘initial password’.

For ip address, click ipv4 section for public ip.

$ ssh [email protected]
The authenticity of host ‘108.61.190.233 (108.61.190.233)’ can’t be established.
ECDSA key fingerprint is 1c:0d:54:ae:88:77:2d:52:1f:58:e8:4e:e0:fa:89:6f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘108.61.190.233’ (ECDSA) to the list of known hosts.
Password for root@vultr:
Last login: Wed Dec 31 15:22:20 2014 from 10.0.2.2
FreeBSD 10.1-RELEASE (GENERIC) #0 r274401: Tue Nov 11 21:02:49 UTC 2014

Welcome to FreeBSD!

Release Notes, Errata: https://www.FreeBSD.org/releases/
Security Advisories: https://www.FreeBSD.org/security/
FreeBSD Handbook: https://www.FreeBSD.org/handbook/
FreeBSD FAQ: https://www.FreeBSD.org/faq/
Questions List: https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/
FreeBSD Forums: https://forums.FreeBSD.org/

Documents installed with the system are in the /usr/local/share/doc/freebsd/
directory, or can be installed later with: pkg install en-freebsd-doc
For other languages, replace “en” with a language code like de or fr.

Show the version of FreeBSD installed: freebsd-version ; uname -a
Please include that output and any error messages when posting questions.
Introduction to manual pages: man man
FreeBSD directory layout: man hier

Edit /etc/motd to change this login announcement.

2. Update FreeBSD security

# freebsd-update fetch
Looking up update.FreeBSD.org mirrors… 5 mirrors found.
Fetching metadata signature for 10.1-RELEASE from update5.freebsd.org… done.
Fetching metadata index… done.
Inspecting system… done.
Preparing to download files… done.

No updates needed to update system to 10.1-RELEASE-p4.

Well, Vultr already do this job 🙂

3. Update pkg

# pkg update
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/freebsd:10:x86:64/latest, please wait…
Verifying signature with trusted certificate pkg.freebsd.org.2013102301… done
Installing pkg-1.4.6…
Extracting pkg-1.4.6: 100%
Message for pkg-1.4.6:
If you are upgrading from the old package format, first run:

# pkg2ng
Updating FreeBSD repository catalogue…
Fetching meta.txz: 100% 940 B 0.9k/s 00:01
Fetching packagesite.txz: 100% 5 MB 5.3M/s 00:01
Processing entries: 100%
FreeBSD repository update completed. 23877 packages processed

4. Install supported packages

# pkg install -y git autoconf bison libxml2 libxslt jpeg png

5. Clone phpng from git

# mkdir ~/tmp
# cd ~/tmp

# git clone https://git.php.net/repository/php-src.git
Cloning into ‘php-src’…
remote: Counting objects: 604751, done.
remote: Compressing objects: 100% (124785/124785), done.
remote: Total 604751 (delta 483783), reused 599215 (delta 478650)
Receiving objects: 100% (604751/604751), 148.38 MiB | 6.68 MiB/s, done.
Resolving deltas: 100% (483783/483783), done.
Checking connectivity… done.

# cd php-src
# git branch phpng origin/phpng
Branch phpng set up to track remote branch phpng from origin.
# git checkout phpng
Switched to branch ‘phpng’
Your branch is up-to-date with ‘origin/phpng’.

6. Build and compile phpng

# ./buildconf
buildconf: checking installation…
buildconf: autoconf version 2.69 (ok)
rebuilding aclocal.m4
rebuilding configure
rebuilding main/php_config.h.in

# ./configure \ --prefix=$HOME/tmp/usr \ --with-config-file-path=$HOME/tmp/usr/etc \ --enable-mbstring \ --enable-zip \ --enable-bcmath \ --enable-pcntl \ --enable-ftp \ --enable-exif \ --enable-calendar \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-wddx \ --with-curl \ --with-mcrypt \ --with-iconv \ --with-gmp \ --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 \ --with-pdo-mysql=/usr \ --with-gettext=/usr \ --with-zlib=/usr \ --with-bz2=/usr \ --with-recode=/usr \ --with-mysqli=/usr/local/bin/mysql_config

a few error :

configure: error: xpm.h not found.

solution :

# pkg install -y libxpm

try re configure

configure: error: freetype-config not found.

solution :

# pkg install -y freetype2

configure: error: Your t1lib distribution is not installed correctly. Please reinstall it.

solution :

# pkg install -y t1lib

configure: error: Unable to locate gmp.h

solution :

# pkg install -y gmp

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

# pkg install -y libmcrypt

configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!

solution :

# pkg install -y mysql56-client

configure: error: Cannot find pspell

Solution :

# pkg install -y aspell

configure: error: Can not find recode.h anywhere under /usr /usr/local /usr /opt.

solution :

# pkg install -y recode

After try a few re configure :

……….

…………….

+——————————————————————–+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+——————————————————————–+

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands

7. Make phpng

# make

I got this error :

ext/iconv/.libs/iconv.o: In function `zm_info_miconv’:
/root/tmp/php-src/ext/iconv/iconv.c:347: undefined reference to `gnu_get_libc_version’
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Re configure with –without-iconv .

This time it work :

………………

………………………

Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP’s phar extension be enabled.
clicommand.inc
directorygraphiterator.inc
directorytreeiterator.inc
invertedregexiterator.inc
pharcommand.inc
phar.inc

Build complete.
Don’t forget to run ‘make test’.

eager for ‘make test’ .

8. Make install phpng

# make install
Installing shared extensions: /root/tmp/usr/lib/php/extensions/no-debug-non-zts-20140815/
Installing PHP CLI binary: /root/tmp/usr/bin/
Installing PHP CLI man page: /root/tmp/usr/php/man/man1/
Installing PHP CGI binary: /root/tmp/usr/bin/
Installing PHP CGI man page: /root/tmp/usr/php/man/man1/
Installing build environment: /root/tmp/usr/lib/php/build/
Installing header files: /root/tmp/usr/include/php/
Installing helper programs: /root/tmp/usr/bin/
program: phpize
program: php-config
Installing man pages: /root/tmp/usr/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /root/tmp/usr/lib/php/
pear//install-pear-nozlib.phar 100% of 3598 kB 6161 kBps 00m01s
[PEAR] Archive_Tar – installed: 1.3.12
[PEAR] Console_Getopt – installed: 1.3.1
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util – installed: 1.2.3
[PEAR] PEAR – installed: 1.9.5
Wrote PEAR system config file at: /root/tmp/usr/etc/pear.conf
You may want to add: /root/tmp/usr/lib/php to your php.ini include_path
/root/tmp/php-src/build/shtool install -c ext/phar/phar.phar /root/tmp/usr/bin
ln -s -f /root/tmp/usr/bin/phar.phar /root/tmp/usr/bin/phar
Installing PDO headers: /root/tmp/usr/include/php/ext/pdo/

Testing php version

# /root/tmp/usr/bin/php -v
PHP 7.0.0-dev (cli) (built: Jan 23 2015 04:48:25)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.8.0-dev, Copyright (c) 1998-2014 Zend Technologies

Great. I can install it on FreeBSD  🙂