一臺服務器綁定多個域名,已經裝了apache,nginx就不使用了,利用apache主機頭名虛擬主機用80端口對應多個網站,萬能的網絡上面有文檔如下:
Aapche 如果需要綁定多個域名到一個IP上,是支持的。需要注意以下2點:
1 必須要開啓 NameVirtualHost開關選項,
如:NameVirtualHost 220.231.220.231:80
2 NameVirtualHost 需要指定具體的端口
例如”:80″,跟<VirtualHost 220.231.32.*:80>對應,否則會報錯:
mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results。
翻譯過來就是: NameVirtualHost 地址,指定端口和不指定端口混合使用是不支持的,將會產生未逾期的後果。
未逾期的後果就是: 第2個不起作用,僅當一個站點設置起作用。
按着做下來:
IncludeOptional conf.d/*.conf
ServerSignature Off
NameVirtualHost 220.231.220.231:80
<VirtualHost 220.231.220.231:80>
ServerAdmin [email protected]
directoryIndex index.html index.php index.htm
ServerName www.aaa.net
DocumentRoot /data/www/wress/
<Directory "/data/www/wress/">
Options -Indexes
Options FollowSymLinks Indexes
AllowOverride All
Require all granted
</Directory>
ErrorLog logs/www.aaa.net-error_log
CustomLog logs/www.aaa.net-access_log common
</VirtualHost>
<VirtualHost 220.231.220.231:80>
ServerAdmin [email protected]
directoryIndex index.html index.php index.htm
ServerName img.aaa.net
#ServerName 220.231.220.231
DocumentRoot /data/www/html/
<Directory "/data/www/html/">
Options -Indexes
Options FollowSymLinks Indexes
AllowOverride All
Require all granted
</Directory>
ErrorLog logs/img.aaa.net-error_log
CustomLog logs/img.aaa.net-access_log common
</VirtualHost>
這樣都可以訪問,apache也可以實現,做個小筆記。