2

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 ?

2
  • Doesn't your site have images, CSS and JavaScript? Feb 23, 2013 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..
    – mahen3d
    Feb 23, 2013 at 11:36

3 Answers 3

1

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
1
  • obvious alternative to compare is to Apache2.0 :)
    – mahen3d
    Feb 23, 2013 at 11:35
1

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).
0

I think this article can be a good explanation of advantages: http://www.aosabook.org/en/nginx.html especially for a slow client case.

1
  • 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.
    – user9517
    Mar 3, 2013 at 20:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .