我在 Centos 7 中安裝了 apache 2.4
普通虛擬主機與所有伺服器 IP 都能正常運作
<VirtualHost *:80>
但是當我為虛擬主機分配特定的 IP 位址並更改主機檔案中的 IP 時
<VirtualHost 11.22.33.44:80>
網站顯示 apache 歡迎頁面
我沒有更改 httpd.conf 中的 Listen 行
Listen 80
答案1
預設連線可能仍配置為偵聽 *:80,並且可能會達到該值。
您將虛擬主機配置為偵聽名稱
如果您的網站的網域為 www.website.com,您可以使用 ServerName 或 ServerAlias 指令偵聽多個虛擬主機的相同 IP 位址
例如
<VirtualHost 11.22.33.44:80>
ServerName www.website.com
DocumentRoot /var/www/website.com/
</virtualHost>
<VirtualHost 11.22.33.44:80>
ServerName www.anotherwebsite.com
DocumentRoot /var/www/anotherwebsite.com/
</virtualHost>