About the Author

Chris Shiflett

Hi, I’m Chris: entrepreneur, community leader, husband, and father. I live and work in Boulder, CO.

PHP and Apache 2

Rich Bowen, a notable member of the Apache community, has commented on PHP's anti-Apache2 FUD. He makes some good points, such as the fact that there's more to Apache 2 than threading.

Rich and I spoke about this issue at ApacheCon. During our brief conversation, I tried to convey my perception of the PHP community's opinion:

  • The main reason to move to Apache 2 is threading.
  • Due to various factors, we cannot guarantee thread safety in every PHP installation.
  • Apache 1's architecture is proven and reliable.

Rich immediately interjected after my first point, pointing out that Apache 2 had much more to offer than threading. Having very little experience with Apache 2 myself, this piqued my curiosity.

Was my perception of the PHP community's opinion wrong, or is this how most of you feel? What are your remaining concerns when PHP is running under Apache 2 (Prefork MPM)?

About this post

PHP and Apache 2 was posted on Mon, 20 Dec 2004. If you liked it, follow me on Twitter or share:


1.Ilia Alshanetsky said:

My own tests which are a bit dated (few months old) show that there is no performance difference between Ap1 and Ap2 (prefork mpm) so why bother switching? In fact when PHP is compiled statically into Ap1 it becomes a lot faster (thanks to no-pic) then dynamically loaded module in Ap2.

The compression available in Ap1 via mod_gzip is sorta replaced by the built-in mod_deflate, but it is not as configurable.

The PHP support for Ap1 sapi is very mature, while Ap2 is relatively new with two competing sapis (Although it seems that most use apache2handler now), which is not as stable then Ap1 still.

Mon, 20 Dec 2004 at 17:32:35 GMT Link

2.Derick Rethans said:

- no static modules

- no proven reliability

And also, why switch to apache 2 when apache 1 is doing the job fine? Without a very good reason to switch over... why bother?

Mon, 20 Dec 2004 at 17:56:39 GMT Link

3.Lukas said:

well I guess the performance is better on windows as windows support for ap1 is hack on feature .. but who is using windows for production anyways?

Mon, 20 Dec 2004 at 18:12:17 GMT Link

4.Markus Wolff said:

If threading is the main concern when using PHP with Apache2, then, well, you can turn it off.

I'm using PHP on several installations (admittedly low to medium-traffic only) with Apache2 and haven't had a problem.

I can understand that people want a system they know and that they can rely on for high-traffic production servers. But then again, I seriously doubt that Apache 1.x will be supported forever. So the PHP community will need to do something about it - better sooner than later.

It doesn't help anyone to say "Hey Apache 1 works great, why bother switching to Apache 2" for the next 20 years or so. If everyone would've thought that way, no software vendor would ever have ported his apps over from MSDOS to Windows.

Mon, 20 Dec 2004 at 18:18:30 GMT Link

5.James said:

The first thing that impressed me when I started hearing about Apache 2 was the support for filters. I'd read plenty of mailing list posts from people who wanted to parse their pages through several modules in the past but hadn't been able to achieve it.

I haven't personally had a chance to use Apache2 and haven't had a project for which I needed any of its features. I'm waiting for an opportunity to really try it out, but for now I'm still in the 'happy with 1.3.x' camp.

Mon, 20 Dec 2004 at 18:18:41 GMT Link

6.botio said:

another benefit from apache2 is that it can serve subversion repositories via mod_dav_svn. that's not really php related, but it may be a quite common setup.

Mon, 20 Dec 2004 at 18:58:49 GMT Link

7.Rich Bowen said:

Just a few responses and comments:

Derick: "no static modules." Huh? In what way does Apache2 have no static modules? As for there being no compelling reason to switch when everything is working -- yes, I completely agree with you. What I object to is the active discouragement of people who do have a reason to migrate.

The compelling reason is, increasingly, nobody will have any interest in continued development on the 1.3 codebase, and it will just become a chore. However, it's also likely that it will continue to be "supported" for as long as people use it.

Botio: Yes, indeed, most of the reasons for moving to Apache2 are in the "not php related" group. This is why it bugs me that it is php, primarily, that seems to talk people out of migrating.

Yeah, I was perhaps a little overboard with my remarks about PHP. My goal was to start a conversation, in the hopes that some good would come out of it. And I'm more than happy to assist in any way that I can, as soon as I am able to do so.

Mon, 20 Dec 2004 at 21:24:47 GMT Link

8.Derick Rethans said:

@Rich Bowen: In apache 1 you have a statically linked mod_php4 - part of your apache binary. For all I know you can not do that with apache 2, where you have to make it a shared object.

Mon, 20 Dec 2004 at 23:26:08 GMT Link

9.Richard@Home said:

"...but who is using windows for production anyways?"

I do, and have for the last year or so. Multi-processor windows 2000 server, hooked up to a sql server back end.

No problems so far :-)

I'm currently testing PHP5 in the same environment.

Tue, 21 Dec 2004 at 10:28:36 GMT Link

10.Nick Bermstein said:

Personally I'd like to see some benchmarks on either the 2.6 kernel or a 2.4 kernel with the threading changes backported. I know that the new threading model has made huge differences with java's threading (amazing speed and stability gains) but I have yet to benchmark AP1 v AP2 under the new threading model.

Tue, 21 Dec 2004 at 19:45:45 GMT Link

11.Chris said:

Realistically, PHP doesn't exist without Apache. And the Apache team is focused on Apache2, not Apache1. That means that all the effort around fixes and enhancements to the Apache platform will be focused on Apache2. Most modern distributions ship with Apache2 now, and that's a huge future install base that PHP needs to work well with. To expect an enterprise to use a software package no longer directly supported by their vendor may be a little hard to swallow.

If you love WordPerfect 5.1, are you going to stick with DOS for the rest of your life, or are you going to accept progress and move forward for your own sake?

FWIW, I'm running php on apache2 (prefork) with no noticable issues myself.

Tue, 21 Dec 2004 at 19:57:11 GMT Link

12.Torin said:

If everyone stuck with the idea of "My current version is working great" and "Why should I switch to something that isn't proven" then how would new versions of anything (Linux, Apache, Windows, MySQL, Postgresql, etc) ever get to a point of being "proven"? The reason you're on Apache 1.3 is because people migrated from previous versions. It may be true (I really don't know) that Apache 2 doesn't improve PHP's performance or usage, but so far I haven't seen anything that proves without a doubt that it makes PHP run worse either. Not to mention the fact that PHP surely isn't the only thing that you're using Apache for now is it?

Tue, 21 Dec 2004 at 20:00:38 GMT Link

13.Ilia Alshanetsky said:

@Chris: PHP would not be as popular without Apache, that much is certain, but it would certainly exist. If you look at the number of web servers PHP can work with you'll realize that. In recent years PHP had also made progress as a stand alone language through things like PHP-GTK, PHP-CLI, ability to use PHP as a milter extension and as a programming language from inside PostgreSQL database. Heck there is even a project (Nanoweb) that developed a webserver written purely in PHP, in fact it's performance is better then that of Apache/PHP-CGI.

Tue, 21 Dec 2004 at 20:06:38 GMT Link

14.Chris Snyder said:

I think Apache2 is worth the upgrade for the simple fact that it *includes* mod_ssl. Also, if htdigest authentication is ever going to be fully implemented, it will probably happen in the 2.0 codebase.

The documentation is nicer, too.

Tue, 21 Dec 2004 at 20:15:22 GMT Link

15.Matt Simpson said:

I appreciate where the PHP team is coming from and I agree with them for the most part; however, I also agree with the many comments regarding software evolution and progress. Sooner or later this philosophy about Apache 2 will have to change as Apache 2+ is the future of the software.

Tue, 21 Dec 2004 at 20:45:18 GMT Link

16.Jeremy Edge said:

It seems to me that this discussion isn't really about Apache 1.3 or 2.0. It's more about IT philosophy. Camp 1 believes that 'If its not broke, don't fix it' and Camp 2 believes 'They put updates out for a reason'.

Tue, 21 Dec 2004 at 20:59:49 GMT Link

17.Ronald said:

If there are problems with the dual usage of apache2 and php. then what can be done to try and resolve these issues. The apache 2.x performs slightly faster on my personal system without php. With PHP it works only so so (linux 2.6, 4gb ram dual proc system with scsi drives).

Tue, 21 Dec 2004 at 21:29:36 GMT Link

18.yacc said:

Well, some good reasons for updates,

at least for new deployments:

Ap1.3 isn't developed further.

Ap2.0 is where all the new stuff gets written for, ...

Ap2.0 is much more portable.

Some basically it boils down, that there are good non-PHP reasons for upgrading (at least new deployments), and there are good non-PHP reasons for not choosing Ap13 (the momentum is shifting or has already shifted to Ap20, depending whom you ask).

Nick Bermstein mentioned "backporting" the new threading model. I'd guess that this is not really a possibility ;) Quite a different concept. ;(

Tue, 21 Dec 2004 at 21:56:00 GMT Link

19.Ian Holsman said:


the line is:

Do not use Apache 2.0.x and PHP in a production environment neither on Unix nor on Windows.

changing it to:

we recommend you install apache2 in 'prefork' mode due to thread safety issues.

This is not about how fast it is, or if apache1.3 is broken or not, or if you perfer running 1.3 over 2.0.

you are scaring people and stopping people installing apache2.

It would be the same as if the apache site put a big banner up and said, due to security issues with phpbb, we don't recommend you install PHP on any production systems.

Tue, 21 Dec 2004 at 22:10:53 GMT Link

20.daPsy said:

As much as I love using PHP/Apache combination, some distribution providers are already abandoning Apache 1.3 from their normal install base and forcing people to acquire Apache 1.3 from their FTP seperately.

Also their automatic update systems no longer support Apache 1.3 on their newest distributions.

Whilst this may sound like a trivial problem from the usual elitist who runs Gentoo, compiles their kernel at least 5 times a day and has unlimited time to tinker on every single program on their systems, it does present a real problem for the time-crippled admin who installs new distribution versions.

Tue, 21 Dec 2004 at 22:35:39 GMT Link

21.Michael Vilain said:

My ISP which serves both my site and a non-profit's site that I manage refuses to upgrade to Apache 2. They're currently running rather old stuff--Apache 1.3 w/ mod_perl + mod_php, MySQL 3.23, php 4.3.4, and perl 5.6 on a Linux 2.2 kernel. It runs just fine for them and the sysadmin doesn't want to change anything because it might break what some customers are running.

Coming from an IT background, I can totally understand this position. Sites that upgrade to "newer stuff" more frequently have less usually. The last contract I had was in a highly controlled environment that tracked all kinds of changes to everything in production. The development machines were essentially production machines for developers to screw up and experiment on without affecting production. Sometimes it would take them 6 months to a year to roll out changes to a system and still there'd be problems. It's much harder when each of your users is _paying_ to keep the systems stable.

I suppose if they had a production _and_ development server, they could go to more recent versions of things. Don't know if a small ISP would bother doing this. Mine hasn't.

Tue, 21 Dec 2004 at 23:15:34 GMT Link

22.Richard said:

Now i worked at a small UK hosting co decided on apache2 + php even tho it was advised against. Never experienced any issues, some fairly high load boxes. I read what the issues were but never had any problems, would love to see some actual examples of sites going pear shaped. As far as i'm concerned, it's an urban myth...

Tue, 21 Dec 2004 at 23:58:48 GMT Link

23.andre said:

been using apache 2 on both windows and linux, works great with PHP. just don't turn on the threading thing with apache 2. besides, the threading thing doesn't really improve performance on linux because of the way the OS handles threads.

but on windows, apache 1.3 vs apache 2.0 is a no-brainer. anybody using the old apache on win32 should be shot! j/k :P

Wed, 22 Dec 2004 at 02:21:46 GMT Link

24.Steve Ryan said:

Funny, I didn't notice the Apache 2.0 warning until I was about to upgrade to the latest PHP today. I have run Apache 2.0.50 for months with PHP 4.3.7 and no problems (and now Apache 2.0.52 for a week or so). There are several domains on this server, but I admit the traffic to all of them is low.

For me, this warning would be a reason not to use PHP before it would convice me to downgrade Apache.

Fri, 07 Jan 2005 at 23:45:22 GMT Link

25.Sjoerd Westerterp said:

I would like to know how to include PHP support in Apache 2 statically. If that is not possible, Apache 1 still outperforms for my purposes. I have seen many messages concerning this matter, yet haven't found a single working solution, nor a reasonable explanation why it is not possible. Until that issue is cleared up, I will stay on 1.3.33

I do believe however the prefork MPM works fine, I have ran Ap2 and PHP without issues, winxp and linux.

Sun, 09 Jan 2005 at 19:00:45 GMT Link

26.Brian said:

I am no expert with Apache, hosting and so on but I do run a web server with a fair amount of traffic. It sees about 800 megs of port 80 traffic each day. I run Apache 2.x.x On a WinXP platform with PHP, Perl, Python, Java (tomcat), and MySQL. I run another server on another port (Sambar Server) because it serves as my SMTP server. I use Apache's reverse proxy to allow people to access the webmail seamlessly.

I would NEVER ever reboot except I messed something up and did reboot. If I would not have done that I would not have restarted my server for over 240 days. So when I see the server reboot time at an average of like 59 days for Win Servers I don't understand.

I just never see why the server must be re-booted. I run some very CPU intensive stuff like Image Magick, WinRar, various other programs that PHP access via the command line for online image editing and other stuff.

Basically I run a very busy server seeing almost 3 hits / second 24/7/365. What would make someone have to reboot their server so often?

Also, again, I am no expert okay but I don' understand threading on Linux/Unix vs. Windows. Which is better in the Apache2 environment?


Sun, 06 Feb 2005 at 18:40:58 GMT Link

27.anonymous said:

Correct if I'm wrong, but Apache is being developed using FreeBSD, an open source Unix, so FreeBSD + Apache makes a great combination! www.freebsd.org

Mon, 07 Feb 2005 at 18:02:47 GMT Link

28.Fanaticus said:

Why reboot a WinXP machine? Cause you'll get hit with a good 10 windows updates ever month :)

Sun, 20 Feb 2005 at 17:02:42 GMT Link

29.James Greenwood said:

If you want a minimal version of Apache 2 and PHP for Windows NT and later, try MiniApache, available at http://james-greenwood.co.uk/. It's comes in at 2MB and includes the latest version of PHP with SQLite database support. You won't regret it! :-)

Sun, 15 May 2005 at 14:43:53 GMT Link

30.temi said:

u are all fools when using apache2

Wed, 28 Sep 2005 at 22:53:00 GMT Link

31.Steve Nisbet said:

Hi folks,

no, people are not fools for using Apache 2, but I do remember people saying exactly the same thing when other dared suggest they move over from NCSA Httpd or CERN, I know that, because I was one of them. Open Source was nowhere near as big as it is now nor as 'stable'. We had jitters moving to Apache 1. I only remember these now as I read through the comments here because I've got used to the mechanism whereby a problem appears and a dedicated community gets to sorting it out within days if not sooner. We share no such faith in MS platforms at all.

We run a collection of webservers which take about 19 hits per second across a cluster, most are Apache 1.3.x running 4.3 series PHP. The boxes though are proprietary and we are moving now back onto a true open source Platform via SLES, which gave me the option to try out Apache 2.x. I held back off moving our production to Apache 2.x for some years because 'it wasnt stable', or because 'it didnt handle PHP well'... and then, just reading this lot I realised thats exactly what we did with the older platform. When NCSA was no longer properly developed we would have had to jump ship anyway, as it was, with a bit of courage and a meaty thick manual I got on board early enough to make sure I knew the ground well enough to run production.

And thats my main compelling reason for shifting to Apache 2.x

But here are some others

a) Native support for SSL, trying to get it going on a suite of 1.3.x machines is a major pain

b) Threading when it happens, its NEVER going to happen in 1.3

c) Working LDAP authentication plus other base types

d) Better mass Virtual hosting

e) Filters

f) Recoded from the ground up

There are others, these are the ones that appealed immediately to me. One that is missing and which I fervently believe in is this though; the community which has built Apache needs support and confidence from the community which has gained so much from it, it has to move on and needs to develop into other areas in the future. PHP badly needed to do this prior to 4, and can any one of you realistically say PHP 3 was better? Had the community who were used to using PHP 3 whinged and whined about the moves, guarantee not only would none of us be using PHP 4, but it would never have got off the shelf and given ASP the pasting it deserved, LAMP would instead mean an old fashion light and neither Apache NOR PHP would have evolved to the degree they both have now.

For the record, we run our servers for nigh a year before they need reboot and on has been running over a year.

Wed, 05 Oct 2005 at 06:44:58 GMT Link

32.John Carney said:

We've been using Apache2 + PHP5 on linux in production on a high load site for well over 6 months now with no problems. I think it's high time people let go of the Ap1+PHP4 security blanket.

Thu, 10 Nov 2005 at 04:17:53 GMT Link

33.Gongzo said:

I am planning to implement Apache server to support an web based submission system which handles heavy engineering drawing. Please advice if Apache is suitable for this and if so, please highlight any drawbacks it may have

Tue, 29 Nov 2005 at 04:08:28 GMT Link

34.mr koz said:

apache2 has a downside?

i have been developing in php for 7 years now. I have 3 servers on the www running a large php CMS farm and the move to apache2 and php5 was more than smoothe, i noticed no changes at all... after the worry and trepidation of upgrading i was left feeling rather silly.

(servers are all debian)

Fri, 09 Mar 2007 at 23:14:45 GMT Link

35.Stefan said:

It is now 2007, a couple years removed since you wrote this. Are their any reasons to continue to stick with apache 1, or is it more advantagous to use version 2 with PHP?

Wed, 23 May 2007 at 21:27:37 GMT Link

36.cad said:

I-m thinking in the update from php4 to php5 but the update from 1.3 to 2 not seems atractive and the benchmarks outhere shows that apache2 is 27% slower than ap1, why change with that bad results? Look here




Wed, 15 Aug 2007 at 04:46:09 GMT Link

Hello! What’s your name?

Want to comment? Please connect with Twitter to join the discussion.