1

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

  1. a PHP site called domain.com
  2. a django site called beta.domain.com
  3. phpmyadmin which will be domain.com/phpmyadmin
  4. phppgadmin, which will be beta.domain.com/phppgadmin
  5. and another django site called domain2.com

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 domain.com it brings up the django site. When I go to domain.com:8080, 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?

4 Answers 4

2

Basically when you put in "domain.com" the web browser actually goes to "domain.com:80" (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.

2

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.

1
  • 1
    i believe you'd need the php-cgi package for this, instead of the libapache2-mod-php package. Nov 9, 2009 at 6:34
1

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;
}
0

Put them on different ports or IPs. Have one server listen on 127.0.0.2 instead of 127.0.0.1, 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).

You must log in to answer this question.

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