threeel
12/5/2016 - 6:40 PM

Compile PHP 7.1 on Mac OS X El Capitan with Homebrew with thread safety enabled. https://wiki.php.net/phpng | https://www.jverdeyen.be/php/p

Compile PHP 7.1 on Mac OS X El Capitan with Homebrew with thread safety enabled. https://wiki.php.net/phpng | https://www.jverdeyen.be/php/phpng-on-ubuntu-trusty/ | http://talks.php.net/froscon15#/phpconf1

1. Install dependencies for PHP 7.1
$ brew update
$ brew tap homebrew/dupes
$ brew install autoconf automake gmp homebrew/versions/bison27 gd freetype t1lib gettext zlib mcrypt
2. Configure PHP 7.1
$ git clone --depth=1 https://github.com/php/php-src.git
$ cd php-src
$ ./buildconf
$ env YACC=`brew --prefix bison27`/bin/bison ./configure \
    --prefix="/usr/local/opt/php7" \
    --with-config-file-path="/usr/local/etc/php7" \
    --enable-mbstring \
    --enable-zip \
    --enable-bcmath \
    --enable-pcntl \
    --enable-ftp \
    --enable-exif \
    --enable-calendar \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-wddx \
    --enable-maintainer-zts \
    --with-curl \
    --with-iconv \
    --with-gmp \
    --with-gd \
    --with-jpeg-dir=`brew --prefix gd` \
    --with-png-dir=`brew --prefix gd` \
    --with-freetype-dir=`brew --prefix freetype` \
    --with-t1lib=`brew --prefix t1lib` \
    --enable-gd-native-ttf \
    --enable-gd-jis-conv \
    --with-openssl \
    --enable-mysqlnd \
    --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd \
    --with-mysql-sock=/tmp/mysql.sock \
    --with-gettext=`brew --prefix gettext` \
    --with-zlib=`brew --prefix zlib` \
    --with-bz2 \
    --with-mcrypt=`brew --prefix mcrypt`
$ make -j `sysctl -n hw.logicalcpu_max`
3. Optional: Deploy OS X package (First finish step 2)
$ env INSTALL_ROOT=$PWD/php7-pkg make install
$ pkgbuild \
  --root php7-pkg \
  --identifier org.denji.php7 \
  --version 7.1.0 \
  --ownership recommended \
  PHP-7.1.0.pkg
4. Install PHP 7.1 to /usr/local/opt/php7
$ make install

5. TODO
  1. export php.ini-{development,production}, php-fpm.ini, extensions ini, php.ini, fpm srcipt launchd in /usr/local/etc/php7/

Links


To uninstall PHP 7.1

$ rm -rvf "/usr/local/opt/php7"
$ rm -rvf "/usr/local/etc/php7"