【问题标题】:Centos7 Apache with passenger enabled - vhosting not working for all configs启用乘客的 Centos7 Apache - 虚拟主机不适用于所有配置
【发布时间】:2015-11-13 22:04:45
【问题描述】:

也许是一个老话题,但我有点坚持使用实际简单的虚拟主机配置。也许我只是错过了一些东西......

我想用一些软件产品配置一个虚拟机。 我已经做了什么: - Jenkins bitnami 堆栈:在 dev.company.com:8080/jenkins 上运行良好

通过 yum 安装 httpd - 通过 WebDAV 设置我的 SVN 存储库:在 dev.company.com/repo 的端口 80 上也可以正常工作

/etc/httpd/conf.d 中的配置文件

<Location /repo>
        DAV svn
        SVNParentPath /srv/svn/repositories/
        SVNListParentPath on
        #<LimitExcept>
        # GET PROPFIND OPTIONS REPORT>
                AuthType Basic
                AuthName "SVN Authorization Realm"
                AuthUserFile /etc/svn-auth-conf
                Require valid-user
        #</LimitExcept>
</Location>
  • 使用 WebRicks 安装和配置 Redmine。在 localhost:3000 上测试:工作正常
  • 通过 HTTPD 使用 Phusion Passenger 运行 Redmine:在 dev.company.com 作为文档根目录运行良好

/etc/httpd/conf.d 中的配置文件

<VirtualHost *:80>
  DocumentRoot /home/redmine/redmine/public
  ServerName dev.company.com
  ServerAlias www.dev.company.com
  DirectoryIndex index.html index.php
  Alias /redmine /home/redmine/redmine/public
  PassengerLogLevel 3
  RailsEnv production
  PassengerDefaultUser apache
  <Location /redmine>
    PassengerBaseURI /redmine
    PassengerAppRoot /home/redmine/redmine/public
  </Location>

  <Directory /home/redmine/redmine/public>
    Order allow,deny
    Allow from all
    AllowOverride All
    Require all granted
    Options -MultiViews
    RailsBaseURI /redmine
    PassengerResolveSymlinksInDocumentRoot on
  </Directory>
 </VirtualHost>

 PassengerPreStart http://dev.company.com

现在我想为 /opt/project 和 /var/www/project 设置另一个 vhost 配置文件

我的 Vhost 配置文件如下所示:

<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName dev.company.com/test
DirectoryIndex index.html index.php
Alias /test /var/www/html
<Directory /var/www/html>
    Options all
    Order allow,deny
    Allow from all
    AllowOverride All
    Require all granted
    PassengerEnabled off
</Directory>

<VirtualHost *:80>
DocumentRoot /opt/test
ServerName dev.company.com/test2
DirectoryIndex index.html index.php
Alias /test /opt/test
<Directory /opt/test>
    Options all
    Order allow,deny
    Allow from all
    AllowOverride All
    Require all granted
    PassengerEnabled off
</Directory>

始终读取第一个配置文件并在 dev.company.com:80 上运行。 以下所有 vhost 配置文件都将被忽略。

具有默认目录设置的默认 httpd.conf 文件,刚刚添加了 NameVirtualHost *:80(默认 Listen 80)。我还将 127.0.0.1 dev.company.com/test... 包含到 /etc/hosts 文件中,并多次重新启动 httpd 服务(以及完整的虚拟机)。

也许这只是一件简单的事情 - 但我没有任何线索。有人有什么想法吗?我真的很感激!

【问题讨论】:

标签: apache passenger virtualhost redmine centos7


【解决方案1】:

据我所知,您不能为同一个 VH 指定两个不同的 DocRoot。您可能需要使用别名,如下所示

<VirtualHost *:80>
  DocumentRoot /home/redmine/redmine/public
  ServerName dev.company.com
  ServerAlias www.dev.company.com
  DirectoryIndex index.html index.php
  Alias /redmine /home/redmine/redmine/public

  Alias /test /var/www/html

  Alias /test2 /opt/test

  PassengerLogLevel 3
  RailsEnv production
  PassengerDefaultUser apache
  <Location /redmine>
    PassengerBaseURI /redmine
    PassengerAppRoot /home/redmine/redmine/public
  </Location>

  <Directory /home/redmine/redmine/public>
    Order allow,deny
    Allow from all
    AllowOverride All
    Require all granted
    Options -MultiViews
    RailsBaseURI /redmine
    PassengerResolveSymlinksInDocumentRoot on
  </Directory>

  <Directory /var/www/html>
    Options all
    Order allow,deny
    Allow from all
    AllowOverride All
    Require all granted
    PassengerEnabled off
  </Directory>

  <Directory /opt/test>
    Options all
    Order allow,deny
    Allow from all
    AllowOverride All
    Require all granted
    PassengerEnabled off
   </Directory>


 </VirtualHost>

【讨论】:

  • 哦,亲爱的...我只是爱你 :D 没想到我错过了这么简单。非常感谢!由于没有匹配的 DirectoryIndex,只是没有让 redmine 像 company.com/redmine 一样工作。但我认为这不会那么困难;)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-03-27
  • 1970-01-01
  • 2015-05-27
  • 2021-08-20
  • 2011-05-04
  • 2017-06-14
  • 2012-08-22
相关资源
最近更新 更多