2

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?

Aaron
  • 2,968
  • 1
  • 22
  • 36
Alex Coplan
  • 575
  • 1
  • 10
  • 18
  • 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 Answers2

2

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.

cjc
  • 24,533
  • 2
  • 49
  • 69
0

They can run alongside each other perfectly happily.

Chopper3
  • 100,240
  • 9
  • 106
  • 238