简体   繁体   English

OSX Apache Virtualhost仅返回默认页面

[英]OSX Apache Virtualhost returns only default page

I have a problem using the build-in apache webserver under ElCapitan. 我在使用ElCapitan下的内置apache网络服务器时遇到问题。

I want to set up my Sites-Directory in my users-directory. 我想在我的用户目录中设置我的站点目录。 This works fine by adding a user config and and so on. 通过添加用户配置等可以很好地工作。 So my localhost/~Fabian gives me the content of /User/Fabian/Sites/index.php. 因此,我的localhost /〜Fabian给了我/User/Fabian/Sites/index.php的内容。

Now I am trying to set up virtual hosts in this directory, eg /User/Fabian/Sites/Projekte/testsite.me/public. 现在,我试图在此目录中设置虚拟主机,例如/User/Fabian/Sites/Projekte/testsite.me/public。

So I activated the virtualhost module and included it in my httpd.conf. 因此,我激活了virtualhost模块并将其包含在我的httpd.conf中。 After this, I set up a virtualhost in the httpd-vhost.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>

I also added the ServerAlias to my hosts file 我也将ServerAlias添加到我的主机文件中

127.0.0.1    testsite.me

Trying to open http://testsite.me shows me the default "It works"-page. 尝试打开http://testsite.me会显示默认的“有效”页面。

Running apachectl configtest gives me an syntax error: 运行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

Line 499 in httpd.conf looks like this: httpd.conf中的499行看起来像这样:

Include /private/etc/apache2/extra/httpd-vhosts.conf

Line 74ff of httpd-vhosts.conf contain the virtualhost I defined above. httpd-vhosts.conf的第74ff行包​​含我上面定义的虚拟主机。

Any idea how to solve this problem? 任何想法如何解决这个问题? What is a VirtualHost section? 什么是VirtualHost部分?

Thank you! 谢谢!

You start your vhost definition with </VirtualHost *:80> That should be <VirtualHost *:80> without the slash. 使用</VirtualHost *:80>开始虚拟主机定义,该定义应为<VirtualHost *:80>不带斜杠。 Although the apache config files are not xml, the Syntax for starting and ending sections are the same; 尽管apache的配置文件不是xml,但是开始和结束部分的语法是相同的。 so you start with <tag> and end with </tag> . 因此您以<tag>开头并以</tag>结尾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM