How to compile thread-safe PHP ?

These days I feel frustrated with the poor status of apache-php server, the connnection is shut down frequently and randomly when concurrency occurs.

I have tried to trace the problem and failed to locate the definite suspicious code. But those strange things never occurred in windows environment!

The most distinguished difference between windows-based php and BSD-based ones is that the latter is thread safe, it may have effects in concurrency environment. So I would like to find the way to build a thread-safe php in BSD enviroment.

But there is no such switch neither in the standard config dialogue nor in the Makefile.

I have no idea then, does anyone know the solution?

Merci!
 
You must configure MPM for apache configuration to handle how much connections and threads apache can handle, and install a PHP accelerator for best php performance.
 
Did you try building PHP with the LINKTHR option set to 'on'? It's off by default, and should take care of any issues you have using threaded libs with PHP.
 
AimelyneM said:
Did you try building PHP with the LINKTHR option set to 'on'? It's off by default, and should take care of any issues you have using threaded libs with PHP.

I don't think that's the same thing as being thread-safe. PHP's stance on thread safety has been, AFAIK, for the longest time: "PHP itself is thread-safe, the problem is that PHP is glue to stick a bunch of other libs together, and there's no guarantee that those are thread-safe".

Linking -lpthread or whatever is probably not going to help that. The real fix here is if you want to use a multi-threaded MPM, and it's not stable (I ran a small box with two sites on it for ages with worker MPM and mod_php and no crashes) then you're probably going to need to switch to php-fcgi, and use modfcgid.
 
How did you manage to start apache MPM with modphp?

How did you manage to compile modphp (libphp5.so) for apache22-worker-mpm so it will not complain about thread safety when loading libphp5.so? My apache22-worker-mpm is throwing this on startup:
Code:
[crit] Apache is running a threaded MPM, but your PHP module is not compiled to be threadsafe. You need to recompile PHP. Pre-configuration failed. Warning: Apache startup failed.

Can you shed some light on how to compile this module so apache won't complain about it not being "threadsafe"?
 
Back
Top