PHP pthreads extension

From ArchWiki
Jump to navigation Jump to search

If you wish to have POSIX multi-threading you will need the pthreads extension (or the parallel extension for PHP 7.4+). To install the pthreads ( or parallel ( extension using pecl you are required to use a compiled version of PHP with the the thread safety support flag --enable-maintainer-zts. Currently, the most clean way to do this would be to rebuild the original package with the proper flag.

Check what packages depend on the php package, for example:

pacman -Qii php
:: php-apache: requires php
:: php-apcu: requires php
:: php-pear: requires php

Remove all of them including 'php', for example:

pacman -R php php-apache php-apcu php-pear

Clone Arch Linux's official package repository:

cd /opt/
git clone
cd packages/php/repos/extra-x86_64

Change the file named PKGBUILD in this folder to add --enable-maintainer-zts, next to the other extensions. It should look like:

--with-xsl=shared \
--with-zip=shared \
--with-zlib \

Make the new packages (you may need to edit permissions before):

makepkg -s

Install the packages you removed:

pacman -U \
php-5.5.8-1-x86_64.pkg.tar.xz \
php-apache-5.5.8-1-x86_64.pkg.tar.xz \
php-pear-5.5.8-1-x86_64.pkg.tar.xz \

On some versions of PHP, php-pear is missing and it is needed to run pecl. As adding --with-pear in the file above does not solve it, you will need to install it separately:

cd /opt/packages/
git clone <nowiki><nowiki>
cd php-pear/
makepkg -i

Then install pthreads:

pecl install pthreads

or install parallel for recent PHP versions:

pecl install parallel

If you installed parallel, you will need to edit /etc/php/php.ini and add the parallel extension, it should look like:


Install the 'apcu' package for APC support back

cd ../../../php-apcu/repos/extra-x86_64/
makepkg -si