Robbie Done
Robbie Done

Reputation: 1157

Running Rails on Apache2

I have a linode server and was running a single website for dev purposes using webrick, now i want to put it into production and use Apache2 which I have installed and is up and running the classic It Work's! page which is expected.

Now I want to run multiple sites on this VPS I am using the current configuration which works fine for striaght HTML but will not run the web apps unless I run them on another port (rails s -p3500 etc) as port 80 is already taken up by Apache.

<VirtualHost *:80>
  ServerName datumpoint.bizmodev.com
  # ServerAlias *.example.com
  DocumentRoot /var/www.bizmodev.com
  <Directory "/var/www.bizmodev.com">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  ServerName homehounduk.co.uk
  ServerAlias *.homehounduk.co.uk
  DocumentRoot /var/www.homehounduk.co.uk
  <Directory "/var/www.homehounduk.co.uk">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

Do i need to use passenger or something else to get this working? i have tried changing the virtual hosts to different ports and stuff but just end up getting a 403.

Any help would be appreciated.

Upvotes: 0

Views: 166

Answers (1)

Nicos Karalis
Nicos Karalis

Reputation: 3773

this line:

<VirtualHost *:80>

you are telling to your apache that it will listen to anything on port 80

it you change to something like this:

<VirtualHost www.myawesomeurl.com:80>

in this case you are telling apache that everything that comes as a request from this address (www.myawesomeurl.com) on port 80 will use that options.

I think you want something like this:

# Basically your home, like: www.myhome.com
<VirtualHost *:80>
  ServerName datumpoint.bizmodev.com
  # ServerAlias *.example.com
  DocumentRoot /var/www.bizmodev.com
  <Directory "/var/www.bizmodev.com">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

# Your custom site
<VirtualHost www.something.com:80>
  ServerName homehounduk.co.uk
  ServerAlias *.homehounduk.co.uk
  DocumentRoot /var/www.homehounduk.co.uk
  <Directory "/var/www.homehounduk.co.uk">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

and dont forget to point the www.something.com to the same ip as the www.myhome.com

Combine this with passenger and you will have one server running many rails apps and many php instances or html pages or anything you want.

Upvotes: 1

Related Questions