1

试图让我的服务器为我的 Rails 应用程序提供服务。

我安装了一个测试应用程序,已经安装了 apache2 和乘客我是否已将以下内容添加到 apache2.conf

# Include the virtual host configurations:
Include sites-enabled/
NameVirtualHost localhost:80
<VirtualHost localhost:80>
      ServerName 192.168.1.67
      DocumentRoot /home/john/Public/test-app
</VirtualHost>

显然,我误解了一些东西,因为我认为这应该将对我的本地 IP 的调用重定向到我的 rails 应用程序。它不是。它将转到默认的 apache index.html。

我究竟做错了什么?

4

3 回答 3

3

更新的答案:我认为您缺少“目录”节点。尝试使用此配置代码:

(假设您的项目路径是:/home/john/Public/test-app)

<VirtualHost *:80>
    DocumentRoot /home/john/Public/test-app/public
    RailsEnv development
    <Directory /home/john/Public/test-app/public>
    AllowOverride all 
    Options -MultiViews
    </Directory>
</VirtualHost>
于 2012-04-06T07:40:57.420 回答
0

我通常是这样做的:

<VirtualHost *:80>
    ServerName mysubdomain.betamaster.us
    DocumentRoot /var/www_home/mysubdomain/
</VirtualHost>

应用这些更改后,请确保执行

/etc/init.d/apache2 reload

为了重新加载服务器配置。

于 2012-04-06T07:40:26.593 回答
0

我在这个问题上有相同的症状,但这是一个不同的问题。我的 apache 安装已经启用了虚拟主机,所以我必须禁用它并使用命令启用我自己的

sudo a2dissite default
sudo a2ensite myapp

其中 default 是 sites-avaliable/ 中默认包含的虚拟主机文件的名称,而 myapp 是我添加的文件。

希望这可以帮助某人。

于 2013-03-31T19:38:46.090 回答