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 have a webserver that is currently running in Apache with some virtualhosts... I would to deploy my django application in this server. But, I would like to use Nginx. (I cant migrate all my virtualserver to Nginx in this moment). So my question is... Can I have Apache and Nginx running in the same server? How can I do that? I have a specific hostname (virtualhost) that my django application will "answer".

Thanks,

share|improve this question

migrated from stackoverflow.com Aug 1 '11 at 0:25

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 0 down vote accepted

Here is a deploy workshop where they do exactly what you are looking for (except that they don't use virtual hosts)

In resume they do a light heavy approach where nginx takes the first request and proxy them to apache or responses an error in case of one. They talk about other stuff like db replication, fabric, etc. Its pretty much worth seeing it

share|improve this answer

When possible I believe it is better to put nginx out in front -- i.e. have it answer at port 80. Configure it so that it is handling all of your non-Django requests, including images, CSS, JS, etc. It is very lightweight and is lightning fast. nginx does not directly support any scripting environements (which is why it is so small and fast), so anything you have that wants/needs an Apache environment can be handled via FastCGI.

WebFaction (a hosting company that I am a happy customer of) does it this way and I have been very impressed with the performance of Django sites in a shared hosting environment.

share|improve this answer

Make nginx listen on different port than Apache and (assuming that Apache is your main server) create VirtualHost that proxies requests to nginx. But I think it's not the best solution - you'll have to connect Django to nginx with FastCGI (or something similar) and you'll end with three servers (Apache, nginx, django fastcgi) instead of just one (Apache with mod_wsgi).

share|improve this answer

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.