Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am working on a new project that will be hosted with Amazon EC2. Speed of requests is of utmost importance, and the low memory footprint of Nginx is very compelling. I've always used Apache, but if significant advantages can be had with Nginx then I would like to switch to that.

I see that a lot of people use Apache + Nginx, but are there any disadvantages as of 2011 to using Nginx with PHP-FPM to serve both static and dynamic content? I know that .htaccess is no longer an option with Nginx, but I also understand that there are ways around this.

Basically, will you get the best performance out of Apache + Nginx, or just Nginx?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The performance will be very similar. In the one scenario you use FastCGI as the communication layer between Nginx and PHP and in the other scenario you use Apache + HTTP as the communication layer. Ultimately the difference between FastCGI and HTTP is not likely to make any difference when you have the overhead of PHP to factor in. Apache will use some extra memory but since it keeps PHP embedded within its own process the speed difference is minor.

Ultimately you should disregard the above unless you really seriously absolutely must have the utmost performance from one server as you are stuck in a location with only enough power for one server, thus making it impossible to scale at all.

The important aspect here is what you're comfortable with and features you require. If you're comfortable with .htaccess then figure out if getting rid of the Apache memory use, the performance hit of .htaccess and the added features of PHP-FPM is worth the investment it is to relearn stuff.

In case it's not obvious I'm a fan of going straight Nginx + PHP-FPM, mostly because of neat features such as the slow-log which provides me with an extra way of making sure everything is working as should be. But it does require relearning, there is no way around .htaccess no longer being available, you cannot magically convert your .htaccess file to nginx format as the nginx configuration is significantly different.

If you do decide to go with Nginx then do yourself a favour and read the documentation. Specifically my nginx primer written as an introduction, the official English documentation from nginx author Igor as well as the wiki directives on location and try_files.

share|improve this answer
    
Just to notice Apache can be used in worker, with fascgi and php-fpm. And .htaccess files can be forbidden (and all .htaccess content put in Directory or Location directives). Which is maybe a first step to try before jumping to nginx. –  regilero May 31 '11 at 12:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.