Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My question is there any advantage using nginx as reverse proxy when most of the content is dynamically generated via php ?

As far as i am concern the nginx is very useful in caching the static content into a cache and serving the multiple requests at once ..

is this true ? or is there any other advantages of the running nginx as a reverse proxy in mostly php driven dynamic content websites ?

share|improve this question
Doesn't your site have images, CSS and JavaScript? – Michael Hampton Feb 23 '13 at 3:33
yes i do have lot of css and images.. is nginx going to cache them too ? but not sure php based templating systems like smarty will work with nginx.. – user1179459 Feb 23 '13 at 11:36

If you ask for advantages, you have to compare it to some alternative:) If you use PHP you will always need some webserver anyway, because PHP itself does not have one.

In general Nginx has cool features like:

  • you mentioned, there are many ways how you can implement caches in Nginx
  • it provides a lot of flexibility due to a big set of modules, especially mod rewrite or mod lua
  • very low on overhead (memory/cpu) compared to alternatives like Apache or Zeus webservers
  • helpful community to answer questions
  • is under active development, so new features come out all the time. f.e. spdy
share|improve this answer
obvious alternative to compare is to Apache2.0 :) – user1179459 Feb 23 '13 at 11:35

The only alternative of interest to nginx+php is to use mod_php in apache. Here are the main differences

  • Virtually all php apps assume they are running in apache, the configuration syntax will always be provided in apache syntax.
  • Static and script pages can be intermixed at will in apache; In nginx, you must distinguish static files from dynamic content from only the request itself. The configuration is somewhat more complex for this reason. Since you won't be serving static content, this probably won't be a problem.
  • there's no in-process equvalent for nginx to the apache mod_php, it must proxy a request to a script interpreter; which is either php-cli -b or uwsgi --plugin php. nginx can start neither process; you'll need to sort that out on your own.
  • nginx is asynchronous, and can easily handle high traffic and slow connections without any extra effort; as long as the php application is fast, you'll be able to handle a bit more traffic almost for free. At my organization, we experienced a nice bump in responsiveness when we dropped apache, even though the php-cli process has fewer threads.
  • If the php worker process crashes (say, when you try to append to a multi-gigabyte log file), it may not be able to deliver an explanation of why over FastCGI; Plain-old CGI doesn't have this issue, but requires a very different configuration on the nginx side (a second-level http server that can start cgi processes, like lighttpd).
share|improve this answer

I think this article can be a good explanation of advantages: especially for a slow client case.

share|improve this answer
We really do prefer that answers contain content not pointers to content. Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Iain Mar 3 '13 at 20:28

Your Answer


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.