![Apache 虛擬子網域](https://rvso.com/image/1344733/Apache%20%E8%99%9B%E6%93%AC%E5%AD%90%E7%B6%B2%E5%9F%9F.png)
我正在嘗試建立虛擬子網域,但編輯 httpd-vhosts.conf 後 apache 無法啟動,錯誤日誌中沒有錯誤。
<VirtualHost 127.0.0.1:80>
ServerAlias *.localhost
UseCanonicalName Off
VirtualDocumentRoot C:/xampp/htdocs/%1
</VirtualHost>
注意:我在 Windows 上透過 xampp 運行 apache。
答案1
這是我在 Linux 中建立虛擬主機的方法:
<VirtualHost 127.0.0.1>
DocumentRoot /var/webapps/testphp
ServerName testphp.home.lan
</VirtualHost>
您可以使用它(替換 DocumentRoot 和 ServerName)並新增
127.0.0.1 testphp.home.lan
在你的/etc/hosts(或windows-os c:\windows\system32\drivers\etc\hosts)中並檢查主apache配置中是否有「錯誤切換器」。可能是您的錯誤日誌已關閉。