It seems to be not the 'core' of PHP, but several of the modules that go with it aren't thread-safe.
Apparently, this really only shows up in the real world under heavy usage, and using the prefork "multi-processing module" should reduce or eliminate the potential problems. I think.
It SOUNDS like the warnings about not using PHP with Apache2 is mainly overcautiousness - every time one of these stories comes up, a few people pop up and say it's working fine for them, and I don't remember seeing anyone pop up and say "yeah, every time I get more than (x) connections at a time everything fails" or anything of the sort.
I'm planning to try it out myself sometime soon...
I known quite some cases where PHP/Apache2 won't really work together since Apache2 begins to segfault, but I was never able to reproduce it mysqlf, all I have are segfaults in the logfiles - and I can't run the whole Apache on my production system within gdb to see where the problem is. I've you ask the PHP guys for help for such a problem, they aren't very cooperative and tell that Apache 2 is not supported...
Just to be the voice of dissention... I'm apparently the one person in the world for whom the PHP+Apache2 combo doesn't actually work right. Yes, it mostly works, but I'm constantly having to close out the windows that pop up when a thread goes boom. Yes, I am running it on XP (with all of the necessary service packs and hotfixes), but that shouldn't invalidate the fact that PHP+Apache2 isn't production-quality stable. And yes, I am 100% sure it is PHP causing the problem, as the errors only started when I started using PHP, and they increase as I convert more and more of my site to PHP.
Now, if I'm getting all these errors, why am I using it? Because it's still better than the alternative. When any DLL goes pop under IIS you get really flaky and esoteric things that start happening. Under Apache2 it just nukes a thread, which Apache2 diligently respawns and goes on with life. I can deal with clicking OK on a dozen windows a day if it means I don't ever have to worry about restarting my web service.
PHP+Apache2 isn't perfect, but it's good enough for what I need.
It's not better than the alternative, using Apache1.
You're very dumb. Either use Apache1, or if you hav some amazing adversity to it (you didn't mention any reaons why you are not using it) then at least edit the source of Apache2 so that it doesn't popup the windows of which you complain.
apache 2 and php work perfectly, i did compile apache with prefork, so as to let apache 2 work the same way old apache did. Also because most linux distros need a lot a tweaking to get a good threaded linux version running.
Again, i'm using apache2 and php in a production env for more than a year now, looks great to me.
There are regular reports on the Horde/IMP lists that PHPs gettext component is broken. As the other poster says, this is some how thread related; PHP not being thread safe. There is at least one report of languages that change within a single page... But it seems that this only happens under heavy load.
It would be interesting to know if PHP 5 will be thread safe, and this usable in production with Apache 2.x
Even if PHP were 100% threadsafe, it generally uses too many libraries for it to be practical to make sure they're ALL threadsafe.
Actually the PHP core is 100 percent threadsafe now, it is only specifically the external libraries which aren't.
If you use PHP w/FastCGI support you wont run into these issues. If you only compile MySQL or Postgres support into your PHP you wouldn't either. But many users frequently also compile in other external libs for things like graphics generation, url manipulation, etc and its these libraries which aren't thread safe and specifically can cause problems in high use environments.
While you could specifically use PHP and Apache2 in total prefork mode, this basically makes it run exactly like the 1.3 series, so then the real question is what's the point of upgrading at all and not just sticking w/1.3?
While you could specifically use PHP and Apache2 in total prefork mode, this basically makes it run exactly like the 1.3 series, so then the real question is what's the point of upgrading at all and not just sticking w/1.3?
Because some servers like the subversion apache module require apache2, and I'd like to not have to run both apache1.3 and 2 in parallel. I am curious as to why the php documentation doesn't mention that using the prefork mpm and php would work fine however.
Given that Apache development is predictably going to continue on the 2.0 branch (which is a questionable point of departure), keeping your site secure with minimum maintenance cost requires using binary releases on the 2.0 platform for web applications.
If you only compile MySQL or Postgres support into your PHP...
You know what? I've been trying to do this very thing for two days now and I can not get Apachetoolbox to compile a pgsql.so so I can have a working PHP installation w/ pgsql support. I have to have this tomorrow and I can not find any place that makes any mention of this. It is ubber annoying. This one stinkin' little shared library is holding up the entire project.:-(
Well I'm not too familiar with Apachetoolbox, but if you just compile Postgres with default options it will pretty much generate a.so that it places under $PREFIX/lib/plpgsql.so
Thanks for the reply. That's not the.so I'm after. The one I'm trying to get compiled is the PHP shared library that PHP loads for pgsql support, pgsql.so ATB is a really handy program that makes it quick and easy to compile and install any number of known Apache modules and accessories. No muss no fuss. Apache gets preconfigured for it and all. That's the pretty intro to it. The other side of the coin is that it doesn't always work. I'm going to have to dump it one of these days and go back to bui
Since PHP 4's inclusion of the Zend Thread-Safe engine, PHP itself has been thread-safe. It is the third-party libraries that extensions link to that are non necessarily thread-safe.
There's a list of libraries and whether or not they are known to be thread-safe here: http://httpd.apache.org/docs-2.0/developer/thread_ safety.html#liblist
The subject of Apache 2/PHP was raised in the Slashdot discussion of the PHP5 beta RC a few days back. One comment [google.com] from a PHP dev (Rasmus) was:
Apache2 has a number of different modes it can work in. These modes are called MPM's. The default MPM is called Worker which is a multithreaded model. PHP, mod_perl, mod_python, and any other similar technology which links directly into the httpd processes will need to be perfectly threadsafe and reentrant to work effectively with a threaded Apache2 mpm. This is doable for the core of PHP, but there are literally hundreds of 3rd party libraries that can be linked into PHP and nobody whether or not these libraries are threadsafe. And figuring out if a specific library is threadsafe or not is non-trivial and it can very from one platform to another. And just to make it even harder, this stuff will appear to work fine until you put it under load or hit very specific race conditions which makes it nearly impossible to debug.
So, since we can't tell you for sure that a threaded Apache2 mpm + PHP will work we do not suggest you use it for a production server. And since we can't know for sure, none of the main PHP developers use this combination for our own servers which compounds the problem because it is not receiving anywhere near the amount of realworld testing required to work out all the little issues above and beyond this threading unknown.
There is an Apache2 mpm, called "prefork", which isn't threaded and basically makes Apache2 look like Apache1. But hey, we have a very good server already that looks like Apache1.
In the end I don't see Apache2+PHP ever becoming a production platform with the current architecture. The only way I see it ever working is to pull PHP out of Apache and use a fastcgi approach. Or, with time, perhaps we will learn how to make sure a library is perfectly threadsafe and safe to use in a multithreaded Apache2.
For now, I really see no reason not to simply use Apache1 if you want a robust, fast and stable web server.
One of the posters [slashdot.org] found this [php.net] more recent comment from Rasmus as well:
We are not talking about just Apache2 here. We are talking about Apache2+an MPM+PHP+3rd Party Libs. The folks at apache.org are only concerned with Apache2 itself, and for serving up static files it is better than Apache1 in many respects. However we have to worry about a lot more stuff here. In fact, we couldn't care less about serving up static files. The main issues as I see them are:
1. Thread safety issues. - It is very difficult to track down threading problems and we don't have decent tools to help us. The thread safety of many 3rd party libraries are unknown quantities and can depend on the OS, libc and even compile flags. - Many distributions seem to ship with the Worker MPM as the default and that is the MPM that gets the most attention. This is a hybrid multi-process, multi-threaded MPM.
2. You can eliminate the threading problem by running the prefork MPM which effectively makes Apache2 behave just like Apache1 in the way it forks processes and serves one request at a time per process. Issues here: - Apache2 itself is rather fringe still. It has approximately a 5% marketshare vs. 65% for Apache1 at the time of this and out of that I would guess the majority are running the Worker MPM. So we are talking about a fringe MPM in a fringe server. This means it has not had anywhere near the attention from people running large production web server farms that it needs for me to comfortably say that this is a solid piece of code with all the kinks worked out. - The benefits of moving to Apache2+prefork are questionable. The new filter API would be one of the benefits, but it sti
Apache2 itself is rather fringe still. It has approximately a 5% marketshare vs. 65% for Apache1 at the time of this and out of that I would guess the majority are running the Worker MPM. So we are talking about a fringe MPM in a fringe server.
In fact, Apache 2's default MPM [apache.org] on unix is Prefork [apache.org], which should work the same way as Apache 1.3, but with several improvements of Apache 2 [apache.org].
My personal opinion is that the PHP development team should tackle thread-safety, but even if they don't they should updat
You can eliminate the threading problem by running the prefork MPM which effectively makes Apache2 behave just like Apache1 in the way it forks processes and serves one request at a time per process.
I can't entirely agree with what Rasmus is saying here. The code for handling of the incoming requests in the MPM is entirely new, cleaner, leaner and better in every respect than Apache 1.
Also, what Rasmus is saying makes one believe that threading is what Apache 2 is all about. First, Apache 1 can be thr
I suppose that for thread-safe implementation one could look at AOLServer. While it won't address PHP issues (one can use PHP with AOLSErver all the same, but the same trhread-safeness argument applies), a built-in Tcl interpreter is probably more than enough to replace the LAMP (with LAPT (Linux/AOLServer/Postgres/Tcl):)).
"There are things that are so serious that you can only joke about them"
- Heisenberg
I've been running PHP/Apache 2 for a while... (Score:4, Interesting)
...and haven't noticed any problems. Why is this advised against?
Re:I've been running PHP/Apache 2 for a while... (Score:5, Interesting)
It seems to be not the 'core' of PHP, but several of the modules that go with it aren't thread-safe.
Apparently, this really only shows up in the real world under heavy usage, and using the prefork "multi-processing module" should reduce or eliminate the potential problems. I think.
It SOUNDS like the warnings about not using PHP with Apache2 is mainly overcautiousness - every time one of these stories comes up, a few people pop up and say it's working fine for them, and I don't remember seeing anyone pop up and say "yeah, every time I get more than (x) connections at a time everything fails" or anything of the sort.
I'm planning to try it out myself sometime soon...
Re:I've been running PHP/Apache 2 for a while... (Score:3, Interesting)
Re:I've been running PHP/Apache 2 for a while... (Score:3, Funny)
Too funny!
Re:I've been running PHP/Apache 2 for a while... (Score:1)
Has nothing to do with MySQL, but with myself.
Re:I've been running PHP/Apache 2 for a while... (Score:3, Funny)
Re:I've been running PHP/Apache 2 for a while... (Score:4, Informative)
Now, if I'm getting all these errors, why am I using it? Because it's still better than the alternative. When any DLL goes pop under IIS you get really flaky and esoteric things that start happening. Under Apache2 it just nukes a thread, which Apache2 diligently respawns and goes on with life. I can deal with clicking OK on a dozen windows a day if it means I don't ever have to worry about restarting my web service.
PHP+Apache2 isn't perfect, but it's good enough for what I need.
Re:I've been running PHP/Apache 2 for a while... (Score:0)
You're very dumb. Either use Apache1, or if you hav some amazing adversity to it (you didn't mention any reaons why you are not using it) then at least edit the source of Apache2 so that it doesn't popup the windows of which you complain.
It's open source for god's sake.
Re:I've been running PHP/Apache 2 for a while... (Score:0)
Re:I've been running PHP/Apache 2 for a while... (Score:1)
Re:I've been running PHP/Apache 2 for a while... (Score:0)
apache 2 and php work perfectly, i did compile apache with prefork, so as to let apache 2 work the same way old apache did. Also because most linux distros need a lot a tweaking to get a good threaded linux version running.
Again, i'm using apache2 and php in a production env for more than a year now, looks great to me.
General Custard.
Re:I've been running PHP/Apache 2 for a while... (Score:4, Informative)
It would be interesting to know if PHP 5 will be thread safe, and this usable in production with Apache 2.x
Re:I've been running PHP/Apache 2 for a while... (Score:3, Informative)
Even if PHP were 100% threadsafe, it generally uses too many libraries for it to be practical to make sure they're ALL threadsafe.
Re:I've been running PHP/Apache 2 for a while... (Score:5, Informative)
Actually the PHP core is 100 percent threadsafe now, it is only specifically the external libraries which aren't.
If you use PHP w/FastCGI support you wont run into these issues. If you only compile MySQL or Postgres support into your PHP you wouldn't either. But many users frequently also compile in other external libs for things like graphics generation, url manipulation, etc and its these libraries which aren't thread safe and specifically can cause problems in high use environments.
While you could specifically use PHP and Apache2 in total prefork mode, this basically makes it run exactly like the 1.3 series, so then the real question is what's the point of upgrading at all and not just sticking w/1.3?
Re:I've been running PHP/Apache 2 for a while... (Score:3, Informative)
Because some servers like the subversion apache module require apache2, and I'd like to not have to run both apache1.3 and 2 in parallel. I am curious as to why the php documentation doesn't mention that using the prefork mpm and php would work fine however.
Re:I've been running PHP/Apache 2 for a while... (Score:2)
going to continue on the 2.0 branch (which is
a questionable point of departure), keeping
your site secure with minimum maintenance cost
requires using binary releases on the 2.0
platform for web applications.
Re:I've been running PHP/Apache 2 for a while... (Score:2)
You know what? I've been trying to do this very thing for two days now and I can not get Apachetoolbox to compile a pgsql.so so I can have a working PHP installation w/ pgsql support. I have to have this tomorrow and I can not find any place that makes any mention of this. It is ubber annoying. This one stinkin' little shared library is holding up the entire project. :-(
Re:I've been running PHP/Apache 2 for a while... (Score:1)
Re:I've been running PHP/Apache 2 for a while... (Score:2)
Re:I've been running PHP/Apache 2 for a while... (Score:4, Informative)
There's a list of libraries and whether or not they are known to be thread-safe here: http://httpd.apache.org/docs-2.0/developer/thread
Re:I've been running PHP/Apache 2 for a while... (Score:1, Informative)
Re:I've been running PHP/Apache 2 for a while... (Score:4, Informative)
One of the posters [slashdot.org] found this [php.net] more recent comment from Rasmus as well:
Re:I've been running PHP/Apache 2 for a while... (Score:2)
In fact, Apache 2's default MPM [apache.org] on unix is Prefork [apache.org], which should work the same way as Apache 1.3, but with several improvements of Apache 2 [apache.org].
My personal opinion is that the PHP development team should tackle thread-safety, but even if they don't they should updat
Re:I've been running PHP/Apache 2 for a while... (Score:2)
I can't entirely agree with what Rasmus is saying here. The code for handling of the incoming requests in the MPM is entirely new, cleaner, leaner and better in every respect than Apache 1.
Also, what Rasmus is saying makes one believe that threading is what Apache 2 is all about. First, Apache 1 can be thr
Re:I've been running PHP/Apache 2 for a while... (Score:2)