Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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., example1.com -> LAMP, example2 -> Rails)? Will you have one site, but with different paths going to LAMP/Rails (e.g., example.com/app1 -> LAMP, example.com/app2 -> 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

2 Answers 2

up vote 2 down vote accepted

So, keeping your existing LAMP stack serving example1.com,, do the following to set up the Rails side on example2.com:

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:

<VirtualHost example2.com:80>
    ServerName example2.com

    ProxyPass / http://localhost:8000/
    ProxyPassReverse / http://localhost:8000
    ProxyPreserveHost on
</VirtualHost>

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

So, your existing VirtualHost for example1.com will handle the LAMP stuff, and the VirtualHost for example2.com 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

 
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.