如何使用没有域名的Passenger / Apache服务Rails应用程序?

我正在尝试在Ubuntu服务器上使用Passenger和Apache来提供Rails应用程序。

Passenger安装说明说我应该添加以下到我的Apacheconfiguration文件 – 我认为这是/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> 

但是,我还没有一个域指向我的服务器,所以我不知道我应该为ServerName参数。 我已经尝试了IP地址,但是当我这样做,重新启动Apache给

 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 

并指向浏览器在IP地址给500内部服务器错误。

我最接近的东西是明智的

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

其中“efate”是我的服务器的主机名。 但是现在把我的浏览器指向服务器的IP地址,只是给出了一个页面,上面写着“It works!” – 据推测这是一个默认页面,但我不知道这是从哪里服务。

我认为我之所以无法得到这个工作的原因是因为没有一个域名。 这是我第一次直接使用Apache,任何帮助都会非常感激!

在进行服务器迁移之前,我发现自己处于这种状况。

在服务器端我正确configuration服务器,然后在本地我使用'鬼'rubygem来修改我的主机(以及与OS X的等效),所以我可以testing所有正确的之前,翻转DNS

你有几个select。 首先,你可以浏览到你的服务器主机名,例如: http:// efate / ? 如果是这样,你就设置好了。

或者,您可以使用Apache的默认主机设置 。

像这样的东西应该为你工作:

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

最后,您可以在本地主机文件中设置一个域,并将其指向您的服务器的IP,然后使用该域来访问服务器。

我有点类似的问题与我的铁轨,除了在这种情况下,我不需要一个域名。 我所做的就是将我的虚拟主机包含在不同的端口上,

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

然后设置Apache来监听那个端口:

 Listen 1234 

这对我有效。

我一直使用的Ubuntu版本在启用了/ etc / apache / sites的虚拟服务器configuration文件中。 我怀疑“It works”页面是从/ var / www / htdocs提供的,并在/ etc / apache / sites-enabled / 000-default文件中指定。 一旦你编辑了这个configuration文件,你可以通过使用机器名称来访问它。