【问题标题】:confused about apache server virtual host对 apache 服务器虚拟主机感到困惑
【发布时间】:2013-03-29 09:48:15
【问题描述】:

所以我在 httpd-vhosts.conf 目录中配置了一个 VirtualHost,但是每当我导航到服务器名称时,它似乎总是给我 httpd.conf 中列出的页面。

我是 apache 网络服务器的新手,不知道我还需要做什么。

在我的 httpd-vhosts.conf 我有

NameVirtualHost *:80

#                                                                                                                                          
# VirtualHost example:                                                                                                                     
# Almost any Apache directive may go into a VirtualHost container.                                                                         
# The first VirtualHost section is used for all requests that do not                                                                       
# match a ServerName or ServerAlias in any <VirtualHost> block.                                                                            
#                                                                                                                                          
<VirtualHost *:80>
   ServerName helloworld.com
   DocumentRoot /Users/username/Desktop/RailsDemo/depot/public/
  <Directory /Users/username/Desktop/RailsDemo/depot/public/>
    AllowOverride all
    Options -MultiViews
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

在我的 httpd.conf 中,我有默认设置,所以安装后我没有更改任何内容。

另外,我已将 helloworld.com 与正确的 IP 地址相匹配。在浏览器中键入 helloworld.com 会产生错误的视图...它会产生 httpd.conf 中指示的视图。

如果这有帮助,我正在尝试做 p。 238 Pragmatic Agile Web Development with Ruby on Rails (4th Edition) -- Iteration K1: Deploying with Phusion Passenger 和 MySQL

任何帮助将不胜感激,谢谢!

【问题讨论】:

    标签: ruby-on-rails ruby apache directory virtual


    【解决方案1】:

    您似乎在运行 Mac OS X。在您的 httpd.conf 中,您将看到这些行;

    # Virtual hosts
    #Include /private/etc/apache2/extra/httpd-vhosts.conf
    

    删除评论,制作它

    # Virtual hosts
    Include /private/etc/apache2/extra/httpd-vhosts.conf
    

    重新启动 apache,这应该会激活您命名的虚拟主机。

    【讨论】:

    • 嗯。现在我有“您无权访问此服务器上的 /”
    • @stack-dot-push 那么Web服务器进程没有权限访问你的主目录。您需要将服务器根目录放在它有权限的其他地方。
    • 这也不起作用...我包括虚拟主机。我也在本地使用 apache web 服务器,所以在我自己的计算机上。那么服务器根不是应该已经拥有权限了吗?我的服务器根设置为“/usr”
    • @stack-dot-push 抱歉,我的意思是 DocumentRoot,它指向 /Users/username/Desktop/RailsDemo/depot/public/,它可能受到其他用户的读取保护,包括运行 Web 服务器的用户。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-14
    • 2012-11-19
    • 1970-01-01
    • 2022-01-08
    • 1970-01-01
    • 2012-11-25
    相关资源
    最近更新 更多