title: How do I create a virtual host in Apache for a rails app
body: <p>I've currently got Ubuntu server running on another computer on my home network. I've installed LAMP for my PHP apps, and ruby for my ruby on rails apps. In my /etc/hosts file I put in a domain name (not real yet) of the app I wish to attach the domain name to. So, for now I guess I'm just simulating typing in that domain and accessing my app on my server when it's finished and I have a real http request coming in for that address. Here is my /etc/hosts file:</p>
  
  <pre><code>27.0.0.1       localhost
  127.0.1.1       mB590
  
  # I want this to point to my rails app
  192.168.24.100  example.com
  
  # The following lines are desirable for IPv6 capable hosts
  ::1     ip6-localhost ip6-loopback
  fe00::0 ip6-localnet
  ff00::0 ip6-mcastprefix
  ff02::1 ip6-allnodes
  ff02::2 ip6-allrouters
  </code></pre>
  
  <p>I've, on my server, created a virtual host file called example.com:</p>
  
  <pre><code>&lt;VirtualHost *&gt;
      RailsEnv development
      ServerName www.example.com
      ServerAlias example.com
      DocumentRoot /var/www/example/public
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>On another computer on the same network I can type in example.com and my apache Welcome page appears. If I type example.com:3000 it points to my rails app as I have setup a virtual host for that to happen. But I want to set it up so that when I type example.com it points to my rails app, without having to specify the port number. I tried the following, then restarted apache and rails server:</p>
  
  <pre><code>&lt;VirtualHost *:3000&gt;
      RailsEnv development
      ServerName www.example.com
      ServerAlias example.com
      DocumentRoot /var/www/example/public
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>.. didn't do anything. I then tried putting in <code>Listen 3000</code>:</p>
  
  <pre><code>Listen 3000
  &lt;VirtualHost *&gt;
      RailsEnv development
      ServerName www.example.com
      ServerAlias example.com
      DocumentRoot /var/www/example/public
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>.. but got this error:</p>
  
  <pre><code>=&gt; Booting WEBrick
  =&gt; Rails 4.1.0 application starting in development on http://0.0.0.0:3000
  =&gt; Run `rails server -h` for more startup options
  =&gt; Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
  =&gt; Ctrl-C to shutdown server
  [2014-05-21 20:17:13] INFO  WEBrick 1.3.1
  [2014-05-21 20:17:13] INFO  ruby 2.0.0 (2014-02-24) [i686-linux]
  [2014-05-21 20:17:13] WARN  TCPServer Error: Address already in use - bind(2)
  Exiting
  /home/martyn/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/webrick/utils.rb:85:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
  .
  .
  .
  </code></pre>
  
  <p>What do I need to do to set this up how I want it? (type in the URL, without the port number and it will be directed to my app)</p>