Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niilante/e9985dcd44d094d77ac07e5f7e30ab3b to your computer and use it in GitHub Desktop.
Save niilante/e9985dcd44d094d77ac07e5f7e30ab3b to your computer and use it in GitHub Desktop.
Compiling PHP 7.4.x with pthreads enabled

Compiling PHP 7.4.x with pthreads (https://github.com/pmmp/pthreads) enabled

Install required libraries

build-essential autoconf libtool bison re2c pkg-config git-core libsqlite3-dev libonig-dev libzip-dev libltdl-dev libbz2-dev libxml2-dev libxslt1-dev libssl-dev libicu-dev libpspell-dev libenchant-dev libmcrypt-dev libpng-dev libjpeg8-dev libfreetype6-dev libmysqlclient-dev libreadline-dev libcurl4-openssl-dev

Download PHP 7.4.x source

cd /var/sources
wget https://www.php.net/distributions/php-7.4.24.tar.gz
tar -zxf php-7.4.24.tar.gz
cd php-7.4.2

Rebuild config

./buildconf --force

Compile PHP with zts enabled

CONFIGURE_STRING="--prefix=/etc/php/7.4z \
--with-config-file-path=/etc/php/7.4z/cli \
--with-config-file-scan-dir=/etc/php/7.4z/conf.d \
--with-bz2 --with-zlib --enable-zip --disable-cgi \
--enable-soap --enable-intl --with-openssl --with-readline --with-curl --enable-ftp \
--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-sockets \
--enable-pcntl --with-pspell --with-enchant --with-gettext --with-gd --enable-exif \
--with-jpeg-dir --with-png-dir --with-freetype-dir --with-xsl --enable-bcmath \
--enable-mbstring --enable-calendar --enable-simplexml --enable-json --enable-hash \
--enable-session --enable-xml --enable-wddx --enable-opcache --with-pcre-regex \
--enable-cli --enable-debug --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data \
--with-mcrypt --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop \
--enable-maintainer-zts"

Note the install path is /etc/php/7.4z

./configure $CONFIGURE_STRING && make && make install

Create CLI config

mkdir /etc/php/7.4z/cli
cp /var/sources/php-7.4.24/php.ini-production /etc/php/7.4z/cli/php.ini

Add php7.4z to path

cd /usr/bin
ln -s /etc/php/7.4z/bin/php php7.4z

Download and build pthreads (pmmp fork: https://github.com/pmmp/pthreads)

cd /var/sources
git clone https://github.com/pmmp/pthreads.git
cd pthreads
/etc/php/7.4z/bin/phpize
./configure --prefix='/etc/php/7.4z' --with-php-config='/etc/php/7.4z/bin/php-config'
make && make install

Enable the pthreads module

cd /etc/php/7.4z/conf.d
echo "extension=pthreads.so" > pthreads.ini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment