5

I have problems with the Pthreads PHP extension. I have compiled PHP with ZTS enabled (--enable-maintainer-zts) and installed the pthreads via pecl and also tried to manually compile the extension.

It seems I don't actually know how to use it. I assumed I would be able to use the Thread class in PHP like any other built-in class, but with no luck as PHP doesn't recognize it. POSIX functions seem to work.

I am using Ubuntu 12.10 Server 64-bit with mod_php 5.4.6.

halfer
  • 19,824
  • 17
  • 99
  • 186
Henri Ruutinen
  • 53
  • 1
  • 1
  • 4
  • I studied apache error log and it seems that pthreads.so cannot be loaded because there's an unknown symbol: sapi_globals_id ... I also tried to compile php with pthreads as a static extension and it makes no difference. – Henri Ruutinen Dec 30 '12 at 12:59
  • The documentation clearly states it's for 5.3. Can we assume that by "5.6.4" you meant "5.4.6"? If so, try going down to 5.3 from 5.4 and see if it works then. If it does, you'll want to file an issue with the maintainer about 5.4 support. – Charles Dec 30 '12 at 18:08
  • Yeah, that was a typo, I am running PHP 5.4.6. At the moment pthreads is up and running. – Henri Ruutinen Jan 04 '13 at 02:29

1 Answers1

3

If you cannot access the extensions classes then it is not loaded.

I think you opened a bug report, to which I responded that your configure line is malformed.

The configure line you want to use is:

./configure --enable-pthreads --enable-maintainer-zts

The above command will build pthreads as a DSO.

./configure --enable-pthreads=static --enable-maintainer-zts

The above command will build pthreads statically into PHP.

Both are equally supported by 5.3, 5.4 and even 5.5.

Additionally, if you are overwriting your system installation then you should use a specific --prefix, for example, if you php executable is at /usr/bin ( which you can ascertain with "which php" ), then --prefix=/usr will overwrite your system installation.

Clean out your old installations ( do make uninstall if the sources are still available ). Start again, ensure you are either, overwriting the system installation or isolating this one completely.

Please update the bug report when you have worked it out.

Baba
  • 94,024
  • 28
  • 166
  • 217
Joe Watkins
  • 17,032
  • 5
  • 41
  • 62
  • Well, I did reinstall the whole Ubuntu and I build php statically with the command you suggested ( --enable-pthreads=static ). No problems at all this time, so it seems there was mishaps in the PHP configuration. Thank you for helping me out. – Henri Ruutinen Jan 04 '13 at 02:34
  • Does ZTS need to be enabled for all installed versions of PHP (i.e. CGI, CLI, and SAPI/Apache)? Or if I am planning to use pthreads only for CLI, can I leave ZTS disabled for the other ones? – robguinness Feb 26 '13 at 20:53
  • Anywhere pthreads is loaded requires ZTS, you can build an isolated instance of PHP with support for pthreads if you so wish ... – Joe Watkins Mar 02 '13 at 12:54