To run thread safe application in PHP, you will need to install PThread manually, because it's not included in the common distribution.

The precondition you should have is all the required PHP plugins and run below commands:

# PULL DOWN the PTHREADS GIT REPO:
git clone https://github.com/krakjoe/pthreads.git
cd pthreads
zts-phpize
./configure --with-php-config=/usr/bin/zts-php-config
make

# COPY EXTENSION TO PHP-ZTS MODULES FOLDER:
cp modules/pthreads.so /usr/lib64/php-zts/modules/.

# ENABLE EXTENSION IN PHP-ZTS, BY CREATING A FILE:
vi /etc/php-zts.d/pthreads.ini

# ADD THIS TO THE FILE AND SAVE:
extension=pthreads.so


You can check to see if you got it working:

zts-php -i | grep -i thread


It should be something like:

/etc/php-zts.d/pthreads.ini
Thread Safety => enabled
pthreads


Now you can invoke programs that need threading and pthreads by using:

zts-php (instead of php)



Below reference contains the required steps for PThread

https://gist.github.com/tegansnyder/ad32f2068e7e30d2692c06df32314ed4

  • No labels