Php – Fastest option for a PHP webserver

httpdperformancePHPweb-server

I need to serve a PHP app that handles lots of requests. I want to know if there's any real benefit in going with anything other than Apache, and what are the pros and cons of the alternatives.

I have some experience using lighttpd and nginx for Rails applications. Are they good contenders for PHP too? Any important setup tricks?

How about PHP accelerators, can they be used with these alternative servers, is it a good idea?

I'm on an OpenSolaris box.

Not sure if relevant, but, later on, I'm planning to put a Varnish proxy/cache in front of this server.

Edit:

I'd like to add that I have absolutely no intention of touching the app. It's the quintessential mess that PHP is famous for, and there's basically no time.

Best Answer

Apache is a good base with mod-php - and adding APC for byte-code caching, and some variable caching will help immensely, in fact, it's the most obvious thing you can do to speed up PHP scripts run-times (also, use Yslow to speed the HTML front-end and make sure that the database is optimised).

There are a few suggestions I'd add though, such as avoiding serving the images and other static content from Apache. I've got a separate (sub-)domain with a dedicated image server (I use thttpd, but nginx is also entirely suitable). Serving the images from an entirely separate domain name (or a CDN) would be ever better though.

NginX also has the advantage of being able to act as a proxy, which has it dealing with inbound connections, and then spoon-feeding the results back out - which means that the back-end producer processes of Apache2/Mod_php can work at full local-network speeds, rather than having to wait for the web-browser clients to catch up.

Varnish can perform additional work beyond what Nginx can do, but I don't know it so well - it might be you could just one one, or the other, but it's unlikely to have to use both.

Related Topic