我正在尝试设置我的虚拟主机。
这是我的主机文件的设置
127.0.0.1 localhost
127.0.0.1 test.local
这是我在 httpd-Vhosts.Conf 文件中的设置
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:/xampp/htdocs/test"
ServerName http://test.local/
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common</VirtualHost>
这就是我在这里得到的错误,
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500
我已经启用了这条线
Include conf/extra/httpd-vhosts.conf
但我不知道我在这里缺少什么来创建虚拟主机。
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:/xampp/htdocs/test"
ServerName test.local
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
有两个问题可能会阻止 Apache 正确解释您的文件:
-
</VirtualHost>
必须在新行中,否则 Apache 无法解析文件(Syntax error
) ServerName
通常放在那里,没有http://
和尾部斜杠
(此外,您不应该使用.local
因为这可能会干扰某些网络内容。