启用了乘客的Centos7 Apache - vhosting不适用于所有配置

时间:2015-08-20 10:03:14

标签: apache passenger virtualhost redmine centos7

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

我想用一些软件产品来配置虚拟机。 我已经做了什么: - Jenkins bitnami stack:在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上正常工作,作为文档Root

/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

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

我的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服务几次(以及完整的虚拟机)。

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

1 个答案:

答案 0 :(得分:1)

据我所知,您可以针对同一VH特定两个不同的DocRoot。您可能需要使用以下Alias

<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>