启用乘客的 Centos7 Apache - 虚拟主机不适用于所有配置
Centos7 Apache with passenger enabled - vhosting not working for all configs
也许是个老话题了,但我有点受困于实际的简单虚拟主机配置。也许我只是错过了一些东西...
我想用一些软件产品配置一个虚拟机。
我已经做了什么:
- 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:作为文档 Root
在 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
设置另一个虚拟主机配置文件
我的虚拟主机配置文件如下所示:
<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。
以下所有虚拟主机配置文件都将被忽略。
默认 httpd.conf 文件,具有默认目录设置,并且刚刚添加了 NameVirtualHost *:80(默认 Listen 80)。我还将 127.0.0.1 dev.company.com/test... 添加到 /etc/hosts 文件并多次重启 httpd 服务(以及完整的虚拟机)。
也许这只是一件简单的事情 - 但我没有任何线索。有人有什么想法吗?非常感谢!
据我所知,您不能为同一个 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>
也许是个老话题了,但我有点受困于实际的简单虚拟主机配置。也许我只是错过了一些东西...
我想用一些软件产品配置一个虚拟机。 我已经做了什么: - 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:作为文档 Root 在 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
设置另一个虚拟主机配置文件我的虚拟主机配置文件如下所示:
<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。 以下所有虚拟主机配置文件都将被忽略。
默认 httpd.conf 文件,具有默认目录设置,并且刚刚添加了 NameVirtualHost *:80(默认 Listen 80)。我还将 127.0.0.1 dev.company.com/test... 添加到 /etc/hosts 文件并多次重启 httpd 服务(以及完整的虚拟机)。
也许这只是一件简单的事情 - 但我没有任何线索。有人有什么想法吗?非常感谢!
据我所知,您不能为同一个 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>