Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I want to host five websites on one VPS I just bought.

  1. a PHP site called
  2. a django site called
  3. phpmyadmin which will be
  4. phppgadmin, which will be
  5. and another django site called

All the django sites will be running with mod_wsgi in apache, and all the PHP sites will be running in nginx with fastcgi.

I'm a developer, not a sysadmin, so I'm having a hard time figuring out the best way to do this. The reason I'm running my PHP from nginx is because I don't want to install mod_php, which allows me to use the worker MPM in apache.

Currently I have nginx running off of port 8080, and apache running off of port 80. When I go to it brings up the django site. When I go to, it brings up the PHP site.

Like I said before, I'm not a server person so this stuff is making my head spin. Is there any way to access stuff from nginx without specifying the port number in the URL?

share|improve this question
up vote 2 down vote accepted

Basically when you put in "" the web browser actually goes to "" (port 80 is the default HTTP port).

You can only assign one application per port on a computer, so only one can listen to the default HTTP port (80) and the other will have to use another port.

There are three ways around this:

1) the proper way would be to use nginx as your main web server (i.e. listening on default http port 80), set Apache to listen on another port (e.g. 8080) then set up a 'reverse proxy' (google is your friend here). This is the ideal set up. It takes a bit more effort to configure but there are hundreds of guides out there that are really helpful.

2) use nginx to serve the django websites (if that is possible?)

3) a quick and easy way (although not recommended), assuming the PHP sites are for webmasters only and the django sites won't need https, you could set up the PHP sites to run over HTTPS. That way you could have Apache running on port 80 (default HTTP) and nginx running on port 443 (default HTTPS). Just put 'https://' instead of 'http://' and you'll get to port 443.

share|improve this answer

IMO, there is no need to run web applications on both web servers.

Due to the fact that I cannot find a good and reliable standalone fastcgi process manager, I would run both Django and PHP applications on Apache, using mod_wsgi for Django and mod_fcgid for PHP apps. The only thing I might consider running on a separate web service would be static files. Both nginx and lighttpd excel at serving static files. By "static files" I do not only mean images, stylesheets or javascript, but also static HTML pages generated by your web applications as part of a caching mechanism.

Regarding mod_php, this will not be needed, since you will be running PHP in fastcgi mode using mod_fcgid. This will also let you use the worker MPM (threaded).

I hope this gives you some pointers.

share|improve this answer
i believe you'd need the php-cgi package for this, instead of the libapache2-mod-php package. – quack quixote Nov 9 '09 at 6:34

You'd better use apache as backend, with nginx proxy at port 80. Nginx can cache pages, and forward specific hosts to apache port 8080.

location / {
    proxy_pass        http://localhost:8000;
    proxy_set_header  Host       $host;
    proxy_set_header  X-Real-IP  $remote_addr;
share|improve this answer

Put them on different ports or IPs. Have one server listen on instead of, if it's just for local development.

For public serving, I'd suggest just using fastcgi (fcgid if using apache) for everything. There's really no need for all these replacements like wsgi; fastcgi is great, and much more flexible (in that you can run python2.5 and python3.1 and ruby side by side, for instance).

share|improve this answer

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.