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!

4 Answers 4

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.

4
  • I have tried <VirtualHost *:80> ServerName default DocumentRoot /root/jpf/public </VirtualHost> but this gives me a 500 Internal Server Error.
    – grifaton
    Jan 17, 2010 at 19:33
  • What do you see in the error log? Also, it might be 'default' instead of 'default'
    – muffinista
    Jan 18, 2010 at 2:23
  • The default is used in the VirtualHost declaration <VirtualHost default:80>
    – emills
    Jan 20, 2010 at 6: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, httpd.apache.org/docs/2.2/vhosts/examples.html#default shows emills syntax.
    – muffinista
    Jan 20, 2010 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

1
  • 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 Jun 7, 2011 at 2: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.

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .