【发布时间】:2016-06-19 20:47:26
【问题描述】:
我在使用 ElCapitan 下的内置 apache 网络服务器时遇到问题。
我想在我的用户目录中设置我的站点目录。通过添加用户配置等可以正常工作。所以我的 localhost/~Fabian 给了我 /User/Fabian/Sites/index.php 的内容。
现在我正在尝试在此目录中设置虚拟主机,例如/User/Fabian/Sites/Projekte/testsite.me/public.
所以我激活了虚拟主机模块并将其包含在我的 httpd.conf 中。在此之后,我在 httpd-vhost.conf 中设置了一个虚拟主机:
</VirtualHost *:80>
ServerAdmin xyz@blubber.de
DocumentRoot "/Users/Fabian/Sites/Projekte/testsite.me/public"
ServerName testsite.me
ErrorLog "/Users/Fabian/Sites/Logs/testsite-error_log"
CustomLog "/Users/Fabian/Sites/Logs/testsite-custom_log" common
</VirtualHost>
我还将 ServerAlias 添加到我的主机文件中
127.0.0.1 testsite.me
尝试打开 http://testsite.me 会显示默认的“它可以工作”页面。
运行apachectl configtest 给我一个语法错误:
httpd: Syntax error on line 499 of /private/etc/apache2/httpd.conf: Syntax error on line 74 of /private/etc/apache2/extra/httpd-vhosts.conf: </VirtualHost without matching <VirtualHost section
httpd.conf 中的第 499 行如下所示:
Include /private/etc/apache2/extra/httpd-vhosts.conf
httpd-vhosts.conf 的第 74 行包含我上面定义的虚拟主机。
知道如何解决这个问题吗?什么是 VirtualHost 部分?
谢谢!
【问题讨论】:
-
Stack Overflow 的 topic 正在编程,这个问题似乎与此无关。我认为您会在更合适的 Stack Exchange 站点(例如 Unix & Linux、Ask Different 或 Super User)中获得更好的响应。
标签: macos apache virtualhost