Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 just set up a virtual machine running Ubuntu Server, with a LAMP stack and OpenSSH installed.

What now would be the best way to enable that server to run both rails and PHP applications? Would it be best to virtualise the two servers on the host server machine? - Or can they run happily alongside each other?

Would Mongrel would be the best option for the rails server?

share|improve this question
You need to be more specific as to what the LAMP and Rails apps will be. Are you going to have two different virtual hosts, one LAMP and the other Rails (e.g., -> LAMP, example2 -> Rails)? Will you have one site, but with different paths going to LAMP/Rails (e.g., -> LAMP, -> Rails)? Anyway, yes, you can do it, mainly by setting up your front end web server to proxy to the desired stack. – cjc Dec 30 '11 at 12:58
separate domains for LAMP/Rails – Alex Coplan Dec 30 '11 at 13:00
up vote 2 down vote accepted

So, keeping your existing LAMP stack serving,, do the following to set up the Rails side on

Run mongrel to listen on port 8000 (or whatever) (FWIW, we use Unicorn, which will handle the workers more elegantly).

On the Apache side, do something like this configuration:


    ProxyPass / http://localhost:8000/
    ProxyPassReverse / http://localhost:8000
    ProxyPreserveHost on

You should peruse your Apache documents on "reverse proxy" and the "ProxyPassReverse" directive for specific details and gotchas.

So, your existing VirtualHost for will handle the LAMP stuff, and the VirtualHost for will proxy requests over to your Rails stack. Your Rails server will listen on port 8000, which is out of the way from LAMP.

share|improve this answer

They can run alongside each other perfectly happily.

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.