New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable pthreads in PHP 5.6 at ubuntu #584

Closed
guotong1988 opened this Issue Mar 31, 2016 · 8 comments

Comments

Projects
None yet
8 participants
@guotong1988

guotong1988 commented Mar 31, 2016

I get the point from
#488
I'm in ubuntu and I run
apt-cache search pthreads
and get the result that seems do not have php things

libevent-pthreads-2.0-5 - Asynchronous event notification library (pthreads)
libilmbase12 - several utility libraries from ILM used by OpenEXR
libpthread-stubs0-dev - pthread stubs not provided by native libc, development files
blcr-testsuite - Userspace tools to Checkpoint and Restart Linux processes
blcr-util - Userspace tools to Checkpoint and Restart Linux processes
lib32cr0 - (32bit) Libraries to Checkpoint and Restart Linux processes
libcr-dbg - Libraries to Checkpoint and Restart Linux processes
libcr-dev - Development files for BLCR
libcr0 - Libraries to Checkpoint and Restart Linux processes
libzthread-2.3-2 - Object-oriented synchronization library for C++
libzthread-dev - Object-oriented synchronization library for C++
pbzip2 - parallel bzip2 implementation
@AedDev

This comment has been minimized.

Show comment
Hide comment
@AedDev

AedDev Mar 31, 2016

Please see my comment here: #488 (comment)

There is no way to enable pthreads like other modules. You need to compile PHP thread safe. In the comment I linked I explained a bit how you can do this.

Installing PHP7 ZTS from PPA

Maybe as an alternative: There is a PPA from Ondřej Surý for PHP7 which is already compiled thread safe. (See here: https://launchpad.net/~ondrej/+archive/ubuntu/php-zts)

To make use of this, do the following:

sudo apt-get install -y language-pack-en-base
LC_ALL=en_US.UTF-8 sudo add-apt-repository ppa:ondrej/php-zts

sudo apt-get update
sudo apt-get install php7.0-zts php7.0-zts-dev

Congratz! PHP7 with thread safety is installed.
Now let's install pthreads:

sudo apt-get install git # If not installed

git clone https://github.com/krakjoe/pthreads.git
cd pthreads

phpize # Here we need the php7.0-zts-dev package

make -j8
sudo make install

sudo mkdir -p /etc/php/7.0-zts/conf.d/ # make sure the path is existing

echo "extension=pthreads.so" > /etc/php/7.0-zts/conf.d/pthreads.ini # Enable the extension

It should work now. Not tested, just guessed based on the installations I did before this way.

Edit: I think I'll write a little script next time for automated install of PHP7 ZTS with pthreads.

~ Morph

AedDev commented Mar 31, 2016

Please see my comment here: #488 (comment)

There is no way to enable pthreads like other modules. You need to compile PHP thread safe. In the comment I linked I explained a bit how you can do this.

Installing PHP7 ZTS from PPA

Maybe as an alternative: There is a PPA from Ondřej Surý for PHP7 which is already compiled thread safe. (See here: https://launchpad.net/~ondrej/+archive/ubuntu/php-zts)

To make use of this, do the following:

sudo apt-get install -y language-pack-en-base
LC_ALL=en_US.UTF-8 sudo add-apt-repository ppa:ondrej/php-zts

sudo apt-get update
sudo apt-get install php7.0-zts php7.0-zts-dev

Congratz! PHP7 with thread safety is installed.
Now let's install pthreads:

sudo apt-get install git # If not installed

git clone https://github.com/krakjoe/pthreads.git
cd pthreads

phpize # Here we need the php7.0-zts-dev package

make -j8
sudo make install

sudo mkdir -p /etc/php/7.0-zts/conf.d/ # make sure the path is existing

echo "extension=pthreads.so" > /etc/php/7.0-zts/conf.d/pthreads.ini # Enable the extension

It should work now. Not tested, just guessed based on the installations I did before this way.

Edit: I think I'll write a little script next time for automated install of PHP7 ZTS with pthreads.

~ Morph

@sagistrauss

This comment has been minimized.

Show comment
Hide comment
@sagistrauss

sagistrauss Jun 15, 2016

@morphesus did an awesome job with the guide above, but just one small thing:
In order for pthreads to be enabled in the CLI, you have to enter /etc/php/7.0-zts/cli/conf.d/ and make a symbolic link to the pthreads.ini or place the file there.

cd /etc/php/7.0-zts/cli/conf.d/
ln -s ../../conf.d/pthreads.ini

Now it works.

root@box:/etc/php/7.0-zts/cli/conf.d# php -m | grep pthreads
pthreads

sagistrauss commented Jun 15, 2016

@morphesus did an awesome job with the guide above, but just one small thing:
In order for pthreads to be enabled in the CLI, you have to enter /etc/php/7.0-zts/cli/conf.d/ and make a symbolic link to the pthreads.ini or place the file there.

cd /etc/php/7.0-zts/cli/conf.d/
ln -s ../../conf.d/pthreads.ini

Now it works.

root@box:/etc/php/7.0-zts/cli/conf.d# php -m | grep pthreads
pthreads

@kalebora

This comment has been minimized.

Show comment
Hide comment
@kalebora

kalebora Jun 29, 2016

Hello
I know you love PHP7
"PHP7 is MUCH more awesome than PHP5 :D " #488 (comment)
"pthreads v3 requires PHP7 or above" #rquirements (pthreads)

I love it too , but unfortunately a lot of PHP library still using PHP5 and it needs adjustments to be working in 7

so I'm hanging with 5 for now , I tried to make it work with pthreads but I couldn't and every installation guide is focusing in php7

"For pthreads 3.x.x you'll need......and you need php7-dev installed - compiled with..." #488 (comment)

I cannot use PHP7 so I’m really happy with pthreads v2 (; , how can I make it work with PHP5 ?

Note: I know my problem not an issue and it's not related pthreads 3 ,I'm sorry for that please help.
Note2: I'm running ubuntu.

kalebora commented Jun 29, 2016

Hello
I know you love PHP7
"PHP7 is MUCH more awesome than PHP5 :D " #488 (comment)
"pthreads v3 requires PHP7 or above" #rquirements (pthreads)

I love it too , but unfortunately a lot of PHP library still using PHP5 and it needs adjustments to be working in 7

so I'm hanging with 5 for now , I tried to make it work with pthreads but I couldn't and every installation guide is focusing in php7

"For pthreads 3.x.x you'll need......and you need php7-dev installed - compiled with..." #488 (comment)

I cannot use PHP7 so I’m really happy with pthreads v2 (; , how can I make it work with PHP5 ?

Note: I know my problem not an issue and it's not related pthreads 3 ,I'm sorry for that please help.
Note2: I'm running ubuntu.

@krakjoe krakjoe closed this Jun 30, 2016

@Cartman34

This comment has been minimized.

Show comment
Hide comment
@Cartman34

Cartman34 Nov 18, 2016

@morphesus It seems we need to do "./configure" to build this source.

Cartman34 commented Nov 18, 2016

@morphesus It seems we need to do "./configure" to build this source.

@ocheems

This comment has been minimized.

Show comment
Hide comment
@ocheems

ocheems Jul 5, 2017

@morphesus I try to follow the commands, as soon as I reach sudo apt-get install php7.0-zts php7.0-zts-dev
I get the following error:

robotics@playground:~$ sudo apt-get install php7.0-zts php7.0-zts-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php7.0-zts : Depends: libapache2-mod-php7.0-zts (>= 7.0.2-1+zts+deb.sury.org~trusty+1~) but it is not going to be installed or
                       php7.0-zts-cgi (>= 7.0.2-1+zts+deb.sury.org~trusty+1~) but it is not going to be installed or
                       php7.0-zts-fpm (>= 7.0.2-1+zts+deb.sury.org~trusty+1~) but it is not going to be installed
              Depends: php7.0-zts-common (>= 7.0.2-1+zts+deb.sury.org~trusty+1~) but it is not going to be installed
 php7.0-zts-dev : Depends: php7.0-zts-cli (>= 7.0.5-4+donate.sury.org~trusty+1) but it is not going to be installed
                  Depends: php7.0-zts-common (= 7.0.5-4+donate.sury.org~trusty+1) but it is not going to be installed
                  Recommends: dh-php but it is not installable
E: Unable to correct problems, you have held broken packages.

ocheems commented Jul 5, 2017

@morphesus I try to follow the commands, as soon as I reach sudo apt-get install php7.0-zts php7.0-zts-dev
I get the following error:

robotics@playground:~$ sudo apt-get install php7.0-zts php7.0-zts-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php7.0-zts : Depends: libapache2-mod-php7.0-zts (>= 7.0.2-1+zts+deb.sury.org~trusty+1~) but it is not going to be installed or
                       php7.0-zts-cgi (>= 7.0.2-1+zts+deb.sury.org~trusty+1~) but it is not going to be installed or
                       php7.0-zts-fpm (>= 7.0.2-1+zts+deb.sury.org~trusty+1~) but it is not going to be installed
              Depends: php7.0-zts-common (>= 7.0.2-1+zts+deb.sury.org~trusty+1~) but it is not going to be installed
 php7.0-zts-dev : Depends: php7.0-zts-cli (>= 7.0.5-4+donate.sury.org~trusty+1) but it is not going to be installed
                  Depends: php7.0-zts-common (= 7.0.5-4+donate.sury.org~trusty+1) but it is not going to be installed
                  Recommends: dh-php but it is not installable
E: Unable to correct problems, you have held broken packages.

@AedDev

This comment has been minimized.

Show comment
Hide comment
@AedDev

AedDev Jul 10, 2017

Hi there @ocheems

It seems you're using Ubuntu too. Which version do you use?

  • Morph

AedDev commented Jul 10, 2017

Hi there @ocheems

It seems you're using Ubuntu too. Which version do you use?

  • Morph
@Muhammad-Elgendi

This comment has been minimized.

Show comment
Hide comment
@Muhammad-Elgendi

Muhammad-Elgendi Oct 7, 2017

Hi @morphesus I try to follow the commands, as soon as I reach make -j8
I get the following error:

Makefile:196: recipe for target 'php_pthreads.lo' failed
make: *** [php_pthreads.lo] Error 1

I am using linuxmint Based on: Debian, Ubuntu 16.04 (LTS)

Any help would be appreciated

Muhammad-Elgendi commented Oct 7, 2017

Hi @morphesus I try to follow the commands, as soon as I reach make -j8
I get the following error:

Makefile:196: recipe for target 'php_pthreads.lo' failed
make: *** [php_pthreads.lo] Error 1

I am using linuxmint Based on: Debian, Ubuntu 16.04 (LTS)

Any help would be appreciated

@AedDev

This comment has been minimized.

Show comment
Hide comment
@AedDev

AedDev Oct 12, 2017

Hi @Muhammad-Elgendi

First off remove the -j8 parameter to disable multithreaded compiling. If this doesn't show any effect consider to open a new ticket.

Kind regards

AedDev commented Oct 12, 2017

Hi @Muhammad-Elgendi

First off remove the -j8 parameter to disable multithreaded compiling. If this doesn't show any effect consider to open a new ticket.

Kind regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment