2

I see on the github PThread project page that php7+ is supported.

I have php7.1.6 on an ubuntu distribution (16.04)

I can't find any PPA that offer php7.1-zts.

How can i enable zts on php7.1 to install pthreads ?

Khorwin
  • 445
  • 1
  • 9
  • 27

2 Answers2

4

This is my setup script

#!/bin/bash

mkdir -p /etc/php7
mkdir -p /etc/php7/cli

git clone https://github.com/php/php-src.git -b PHP-7.0.17 --depth=1
cd php-src/ext
git clone https://github.com/krakjoe/pthreads -b master pthreads

cd ..

./buildconf --force

./configure --prefix=/etc/php7 --with-bz2 --with-zlib --enable-zip --disable-cgi \
   --enable-soap --enable-intl --with-mcrypt --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 --with-config-file-path=/etc/php7/cli \
   --with-config-file-scan-dir=/etc/php7/etc --enable-cli --enable-maintainer-zts \
   --with-tsrm-pthreads --enable-debug --enable-fpm \
   --with-fpm-user=www-data --with-fpm-group=www-data

make && make install

chmod o+x /etc/php7/bin/phpize
chmod o+x /etc/php7/bin/php-config

cd ext/pthreads*
/etc/php7/bin/phpize

./configure --prefix=/etc/php7 --with-libdir=/lib/x86_64-linux-gnu --enable-pthreads=shared --with-php-config=/etc/php7/bin/php-config

make && make install

cd ../../
cp -r php.ini-development /etc/php7/cli/php.ini

cp php.ini-development /etc/php7/cli/php-cli.ini
echo "extension=pthreads.so" > /etc/php7/cli/php-cli.ini
echo "zend_extension=opcache.so" >> /etc/php7/cli/php.ini

ln --symbolic /etc/php7/bin/php /usr/bin/php

export USE_ZEND_ALLOC=0

Also you can use my docker-container docker pull buildok/zts

buildok
  • 785
  • 6
  • 7
  • 1
    Thanks, it's seem to work fine as is. i will test with php 7.1 branch. Do you now if it's possible to have a php apache module when compiling from sources ? – Khorwin Jun 26 '17 at 14:37
  • @Khorwin I use nginx usually. If you need to apache-mod support, you can add a parameter in ./configure --with-apxs2=/usr/local/apache2/bin/apxs look detail about this http://php.net/manual/en/install.unix.apache2.php – buildok Jun 26 '17 at 16:57
  • 2
    @Khorwin Pthreads cannot be used in a web server environment, so you will not be able to have pthreads enabled if PHP is loaded as an Apache module. – tpunt Jun 26 '17 at 19:09
  • @buildok You have debug mode enabled - that probably isn't desirable for most people here. Also, the TSRM defaults to POSIX threads, so there's no real need to specify it. – tpunt Jun 26 '17 at 19:11
  • Maybe you are right, anyway I advise to use ./configure --help to find out about these parameters before compile – buildok Jun 26 '17 at 19:24
  • I have some problems with 7.1 today.. so the solutions was use this version of pthreads: https://github.com/neomacedo/pthreads/releases/tag/v3.1.7-beta.1 Appear to be the master only compatible with 7.2+ now – Helcio R. Macedo Pandelo Sep 28 '17 at 13:35
  • Hi. This is great in that it is a functional answer...but one question, why are you installing binaries under /etc? That's very unusual; binaries generally go under some path like /usr/local/bin... – Brian A. Henning Aug 20 '18 at 18:36
  • Not working, I get error:" ‘zend_op_array {aka struct _zend_op_array}’ has no member na med ‘run_time_cache’; did you mean ‘run_time_cache__ptr’?" at 2nd command "make && make install" – Jerem Lachkar Aug 04 '20 at 15:27
  • @JeremLachkar https://github.com/krakjoe/pthreads/issues/944 – buildok Aug 06 '20 at 14:54
  • I finally used new PHP 7.4 librairy "Parallel". Don't forget to git checkout PHP-7.4, to compile PHP from source (it was a nightmare to compile using master branch) – Jerem Lachkar Aug 06 '20 at 16:04
0

On Ubuntu server

I changed the version to 7.4.16

git clone https://github.com/php/php-src.git -b PHP-7.0.17 --depth=1

I had to install a few dependencies, before being able to recompile PHP.

The packages needed were:

apt install bison re2c zlib1g-dev sqlite3 libsqlite3-dev libbz2-dev libcurl4-openssl-dev libenchant-dev libonig-dev libpspell-dev libedit-dev libreadline-dev libxslt-dev

Also WARNING: unrecognized options: --enable-zip, --with-mcrypt, --with-gd, --with-jpeg-dir, --with-png-dir, --with-freetype-dir, --enable-hash, --enable-wddx, --with-pcre-regex

So with php 7.4 you probably want to do: ./configure --prefix=/etc/php7 --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 \ --enable-exif --with-xsl \ --enable-bcmath --enable-mbstring --enable-calendar --enable-simplexml --enable-json \ --enable-session --enable-xml --enable-opcache \ --with-config-file-path=/etc/php7/cli \ --with-config-file-scan-dir=/etc/php7/etc --enable-cli --enable-maintainer-zts \ --with-tsrm-pthreads --enable-debug --enable-fpm \ --with-fpm-user=www-data --with-fpm-group=www-data

After you will find that php7.4 is not compatible with pthreads and you will find this error, where the maintainer has stopped development of pthreads and moved to parallel. https://github.com/krakjoe/pthreads/issues/929

Jonni2016aa
  • 144
  • 1
  • 3