sudo apt install \
autoconf \
bison \
build-essential \
libbz2-dev \
libc-client-dev \
libcurl4-gnutls-dev \
libgmp-dev \
libjpeg-dev \
libkrb5-dev \
libmagickcore-dev \
libmagickwand-dev \
libmcrypt-dev \
libmemcached-dev \
libpng-dev \
libreadline-dev \
libssl-dev \
libtidy-dev \
libwebp-dev \
libxml2-dev \
libxpm-dev \
libxslt-dev \
libyaml-dev \
libzip-dev \
linux-libc-dev \
pkg-config \
re2c
brew install \
autoconf \
automake \
bison \
bzip2 \
curl \
gmp \
icu4c \
jpeg \
libedit \
libiconv \
libmcrypt \
libpng \
libxml2 \
libxslt \
libzip \
libtool \
make \
openssl \
re2c \
readline \
tidy-html5 \
zlib
git clone [email protected]:phpenv/phpenv.git ~/.phpenv
Then follow the instruction from phpenv repo.
git clone [email protected]:php-build/php-build.git ~/.phpenv/plugins/php-build
git clone [email protected]:sergeyklay/phpenv-config-add.git ~/.phpenv/plugins/phpenv-config-add
git clone [email protected]:sergeyklay/phpenv-pear-setup.git ~/.phpenv/plugins/phpenv-pear-setup
export PHP_BUILD_ZTS_ENABLE=on
export PHP_BUILD_XDEBUG_ENABLE=off
export PHP_BUILD_EXTRA_MAKE_ARGUMENTS=-j"$(getconf _NPROCESSORS_ONLN)"
export PHP_BUILD_TMPDIR=~/src/php
mkdir -p $PHP_BUILD_TMPDIR
php-build --ini development 7.2.20 $(phpenv root)/versions/7.2.20-zts-debug/
Example of script to print install instructions for multiple PHP versions:
for v in 7.0.33 7.1.30 7.2.20 7.3.7; do
for z in on off; do
for d in --enable-debug --disable-debug; do
[ "$z" = "on" ] && zts=zts || zts=nts
[ "$d" = "--enable-debug" ] && dbg=debug || dbg=release
echo \
PHP_BUILD_ZTS_ENABLE=$z \
PHP_BUILD_XDEBUG_ENABLE=off \
PHP_BUILD_EXTRA_MAKE_ARGUMENTS=-j"$(getconf _NPROCESSORS_ONLN)" \
PHP_BUILD_CONFIGURE_OPTS="\"--disable-fpm --disable-phpdbg $d\"" \
php-build --ini development $v $(phpenv root)/versions/$v-$zts-$dbg/
done
done
done
This will print lines like this:
PHP_BUILD_ZTS_ENABLE=on \
PHP_BUILD_XDEBUG_ENABLE=off \
PHP_BUILD_EXTRA_MAKE_ARGUMENTS=-j20 \
PHP_BUILD_CONFIGURE_OPTS="--disable-fpm --disable-phpdbg --enable-debug" \
php-build --ini development 7.1.30 /home/USER/.phpenv/versions/7.1.30-zts-debug/
Feel free to disable any extension using PHP_BUILD_CONFIGURE_OPTS
variable. For examle to disabe gd
:
- PHP_BUILD_CONFIGURE_OPTS="--disable-fpm --disable-phpdbg --enable-debug"
+ PHP_BUILD_CONFIGURE_OPTS="--disable-fpm --disable-phpdbg --disable-gd --enable-debug"
macOS users will need to create a symlink for openssl and customize PHP_BUILD_CONFIGURE_OPTS
. For example:
Creating symlinks:
cd /usr/local/include
ln -s ../opt/openssl/include/openssl .
Customizing PHP_BUILD_CONFIGURE_OPTS
:
export PHP_BUILD_CONFIGURE_OPTS="\
--disable-fpm \
--disable-phpdbg \
--enable-debug \
--with-gettext=$(brew --prefix gettext) \
--with-bz2=$(brew --prefix bzip2) \
--with-curl=$(brew --prefix curl) \
--with-gmp=$(brew --prefix gmp) \
--with-iconv=$(brew --prefix libiconv) \
--with-icu-dir=$(brew --prefix icu4c) \
--with-jpeg-dir=$(brew --prefix jpeg) \
--with-libedit=$(brew --prefix libedit) \
--with-libxml-dir=$(brew --prefix libxml2) \
--with-libzip=$(brew --prefix libzip) \
--with-mcrypt=$(brew --prefix libmcrypt) \
--with-png-dir=$(brew --prefix libpng) \
--with-readline=$(brew --prefix readline) \
--with-tidy=$(brew --prefix tidy-html5) \
--with-xsl=$(brew --prefix libxslt) \
--with-zlib=$(brew --prefix zlib)"
Note: For PHP 5.x - 7.0.x on macOS you'll need buffio.h
:
ln -s $(brew --prefix tidy-html5)/include/tidybuffio.h $(brew --prefix tidy-html5)/include/buffio.h
For PHP ^7.0 on macOS if you want build ZTS version - you'll nedd to apply patch for PHP sources:
On Mac thread_local and __thread are not ABI compatible, in addition, thread_local
comes with additional overhead, __thread seems to be the most suitable linkage to use
regardless of c++/c
---
TSRM/TSRM.h | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h
index 3e3e7d656e48..d2be3184408a 100644
--- a/TSRM/TSRM.h
+++ b/TSRM/TSRM.h
@@ -159,14 +159,10 @@ TSRM_API void *tsrm_get_ls_cache(void);
TSRM_API uint8_t tsrm_is_main_thread(void);
TSRM_API const char *tsrm_api_name(void);
-#if defined(__cplusplus) && __cplusplus > 199711L
-# define TSRM_TLS thread_local
+#ifdef TSRM_WIN32
+# define TSRM_TLS __declspec(thread)
#else
-# ifdef TSRM_WIN32
-# define TSRM_TLS __declspec(thread)
-# else
-# define TSRM_TLS __thread
-# endif
+# define TSRM_TLS __thread
#endif
#define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1)
cat <<EOT >> $(phpenv prefix)/etc/conf.d/999-defaults.ini
memory_limit=-1
variables_order=EGPCS
opcache.enable_cli=1
error_reporting=-1
display_errors=1
display_startup_errors=1
date.timezone=UTC
EOT
git clone https://github.com/phalcon/php-zephir-parser.git $PHP_BUILD_TMPDIR/source/zephir-parser
cd $PHP_BUILD_TMPDIR/source/zephir-parser
phpenv local 7.2.20-zts-debug && phpenv rehash
phpize
./configure --with-php-config=$(phpenv which php-config) --enable-zephir-parser
make
make install
echo extension=zephir_parser.so > $(phpenv prefix)/etc/conf.d/zephir_parser.ini
cd $PHP_BUILD_TMPDIR/source/7.2.20/ext/gmp
phpenv local 7.2.20-zts-debug && phpenv rehash
phpize
./configure
make
make install
echo extension=gmp.so > "$(phpenv prefix)/etc/conf.d/gmp.ini"
phpenv local 7.2.20-zts-debug && phpenv rehash
phpenv pear-setup
export PHP_PEAR_PHP_BIN=$(phpenv which php)
printf "\n" | pecl install --force igbinary 1> /dev/null
printf "\n" | pecl install --force imagick 1> /dev/null
printf "\n" | pecl install --force yaml 1> /dev/null
printf "\n" | pecl install --force memcached 1> /dev/null
printf "\n" | pecl install --force psr 1> /dev/null
printf "\n" | pecl install --force apcu_bc 1> /dev/null