2

I am trying to serve a Rails application using Passenger and Apache on a Ubuntu server.

The Passenger installation instructions say I should add the following to my Apache configuration file - I assume this is /etc/apache2/httpd.conf.

<VirtualHost *:80>
   ServerName www.yourhost.com
   DocumentRoot /somewhere/public    # <-- be sure to point to 'public'!
   <Directory /somewhere/public>
      AllowOverride all              # <-- relax Apache security settings
      Options -MultiViews            # <-- MultiViews must be turned off
   </Directory>
</VirtualHost>

However, I do not yet have a domain pointing at my server, so I'm not sure what I should put for the ServerName parameter. I have tried the IP address, but when I do that, restarting Apache gives

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Sun Jan 17 12:49:26 2010] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Sun Jan 17 12:49:36 2010] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results

and pointing the browser at the IP address gives a 500 Internal Server Error.

The closest I have got to something sensible is with

<VirtualHost efate:80>
   ServerName efate 
   DocumentRoot /root/jpf/public
   <Directory /root/jpf/public>
      AllowOverride all
      Options -MultiViews
   </Directory>
</VirtualHost>

where "efate" is my server's host name. But now pointing my browser at the server's IP address just gives a page saying "It works!" - presumably this is a default page, but I'm not sure where this is being served from.

I might be wrong in thinking that the reason I have been unable to get this to work is related to not having a domain name. This is the first time I have used Apache directly - any help would be most gratefully received!

grifaton
  • 141
  • 1
  • 4

4 Answers4

1

You've got a few options. First, can you just browse to your server hostname, ie: http://efate/ ? If so, you're set.

Alternatively, you can use apache's default host settings.

Something like this should work for you:

<VirtualHost *:80>
      ServerName _default_
      DocumentRoot /root/jpf/public
</VirtualHost>

Finally, you can setup a domain in your local hosts file, and point it to your server's IP, and use that domain to hit the server.

muffinista
  • 1,236
  • 8
  • 6
  • I have tried ServerName _default_ DocumentRoot /root/jpf/public but this gives me a 500 Internal Server Error. – grifaton Jan 17 '10 at 19:33
  • What do you see in the error log? Also, it might be 'default' instead of '_default_' – muffinista Jan 18 '10 at 02:23
  • The _default_ is used in the VirtualHost declaration – emills Jan 20 '10 at 06:18
  • It looks like maybe the syntax changed at some point, but the syntax above should still work. I'm using it in an apache 2.2.3 install. Either way, http://httpd.apache.org/docs/2.2/vhosts/examples.html#default shows emills syntax. – muffinista Jan 20 '10 at 19:29
1

I find myself in this situation before doing a server migration.

On the server end I configure the server correctly, and then locally I use the 'ghost' rubygem to modify my hosts (well the OS X equivalent), so I can test all is correct before flipping over DNS

aussiegeek
  • 234
  • 3
  • 11
  • This is the easiest and most straightforward solution here, it means you are testing your server configuration as it is and can worry about DNS later – hellomynameisjoel Jun 07 '11 at 02:15
0

I sort of had a similar problem with my rails, except that in this case, I didn't need a domain name. What I did was to setup my vhost contain on a different port all together:

<VirtualHost *:1234>
   ServerName domain.com
   RailsEnv development
   DocumentRoot /path/to/app/public
   <Directory /path/to/app/public>
      AllowOverride all
      Options -MultiViews
   </Directory>
</VirtualHost>

Then setup apache to listen to that port:

Listen 1234

That worked for me.

Rilindo
  • 5,078
  • 5
  • 28
  • 46
0

The versions of Ubuntu I've been using have the virtual server config files in /etc/apache/sites-enabled. I suspect that the "It works" page is being served from /var/www/htdocs and is specified in the /etc/apache/sites-enabled/000-default file. Once you've edited this config file you might be able to access it just by using the machine name.

Phil
  • 403
  • 6
  • 14