在 Apache 中提供多个根目录
Serving multiple root directories in Apache
我希望我的两个站点:flowers.loc (Drupal 8) 和 honey.loc (Drupal 7) 站点在 Apache (v: 2.234) 上本地运行。
flowers.loc 的第一个目录:
Sites/drupal8/docroot
honey.loc 的第二个目录:
Sites/drupal7/docroot
我在 httpd、apache 配置文件中有这个设置:
<VirtualHost *:80>
DirectoryIndex index.html index.php
DocumentRoot /User/Vizzaro/Sites
<Directory "/User/Vizzaro/Sites">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
查看 https://httpd.apache.org/docs/2.2/vhosts/examples.html 了解如何设置虚拟主机。您的配置文件只有一个虚拟主机条目,但每个站点都需要一个条目。此外,您的配置缺少 ServerName。试试这个:(未经测试)
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
ServerName flowers.loc
DocumentRoot /User/Vizzaro/Sites/drupal8/docroot
# Other directives here
</VirtualHost>
<VirtualHost *:80>
ServerName honey.loc
DocumentRoot /User/Vizzaro/Sites/drupal7/docroot
# Other directives here
</VirtualHost>
并确保 honey.loc 和 flowers.loc 都指向您的 apache 运行 所在机器的 IP。尝试 ping flowers.loc
- 如果这会导致类似 Name or service not known
的错误,您可能需要编辑主机文件来修复它。
我希望我的两个站点:flowers.loc (Drupal 8) 和 honey.loc (Drupal 7) 站点在 Apache (v: 2.234) 上本地运行。
flowers.loc 的第一个目录:
Sites/drupal8/docroot
honey.loc 的第二个目录:
Sites/drupal7/docroot
我在 httpd、apache 配置文件中有这个设置:
<VirtualHost *:80>
DirectoryIndex index.html index.php
DocumentRoot /User/Vizzaro/Sites
<Directory "/User/Vizzaro/Sites">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
查看 https://httpd.apache.org/docs/2.2/vhosts/examples.html 了解如何设置虚拟主机。您的配置文件只有一个虚拟主机条目,但每个站点都需要一个条目。此外,您的配置缺少 ServerName。试试这个:(未经测试)
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
ServerName flowers.loc
DocumentRoot /User/Vizzaro/Sites/drupal8/docroot
# Other directives here
</VirtualHost>
<VirtualHost *:80>
ServerName honey.loc
DocumentRoot /User/Vizzaro/Sites/drupal7/docroot
# Other directives here
</VirtualHost>
并确保 honey.loc 和 flowers.loc 都指向您的 apache 运行 所在机器的 IP。尝试 ping flowers.loc
- 如果这会导致类似 Name or service not known
的错误,您可能需要编辑主机文件来修复它。