I want to host five websites on one VPS I just bought.
- a PHP site called domain.com
- a django site called beta.domain.com
- phpmyadmin which will be domain.com/phpmyadmin
- phppgadmin, which will be beta.domain.com/phppgadmin
- 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?
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.
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.
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.
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).