Apr 29, 2016

PHP 7 on Mac OS X custom build, Xdebug and Composer

How to build PHP 7 on Mac OS X.


  1. Install XCode 
  2. Add command line tools. They can be added with command xcode-select --install
  3. Download latest version from http://php.net/downloads.php
  4. Install OpenSSL with a homebrew: brew install openssl
  5. Find your Openssl version: ls /usr/local/Cellar/openssl/
  6. Use it in the configure command:
'./configure' \
'--prefix=/usr/local' \
'--with-config-file-path=/usr/local/etc' \
'--enable-debug' \
'--with-openssl=/usr/local/Cellar/openssl/1.0.2g' \
'--enable-mbstring' \
'--enable-fpm' \
'--with-config-file-path=/usr/local/etc' \
'--enable-mysqlnd' \
'--with-pdo-mysql' \
'--with-mysqli=shared' \
'--with-bz2=shared,/usr/lib' \
'--enable-bcmath=shared' \
'--with-curl=shared' \
'--with-freetype-dir=/usr' \
'--with-png-dir=/usr' \
'--with-gd=shared' \
'--enable-gd-native-ttf' \
'--with-jpeg-dir=shared,/usr' \
'--with-zlib=shared' \
'--with-xsl=shared' \
'--with-iconv=shared' \
'--with-pear' \
'--with-mhash=shared' \
'--disable-exif' \
'--disable-ftp' \
'--disable-sockets' \
'--disable-sysvsem' \
'--disable-sysvshm' \
'--disable-shmop' \
'--disable-ipv6' \
'--disable-posix' \
'--with-layout=PHP'

Note: openssl and mbstring extensions are required by Composer, it is convenient to compile them as non-shared.

7. Compile and install: make; make install 

8. Copy "php.ini-development" file from the source folder to /usr/local/etc/php.ini and update

9. Add XDebug: pecl install xdebug
Add "zend_extension=/usr/local/lib/php/extensions/debug-non-zts-20151012/xdebug.so" to /usr/local/etc/php.ini

10. Make alias in ~/.bash_profile to call php without xdebug
alias composer='php -n ~/bin/composer'

Feb 29, 2016

Docker image for PHP with common extensions and Composer

I created a Docker image for PHP 7.

The official PHP image lacks many commonly used extensions.
My image is extending it, having added most of extensions one uses in every day work, and a composer. It is  usable to set up a PHP-FPM service quickly, without compiling extensions manually. Just init the configs in a mounted folders, edit configs, disable unused extensions, and you are done.

The image is here: https://hub.docker.com/r/grigori/phpextensions/

Further I will add docker compose config file to set PHP together with MySQL and Nginx.