一台服务器绑定多个域名,已经装了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 postmaster@aaa.net
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
ErrorLog logs/www.aaa.net-error_log
CustomLog logs/www.aaa.net-access_log common
<VirtualHost 220.231.220.231:80>
ServerAdmin postmaster@aaa.net
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
ErrorLog logs/img.aaa.net-error_log
CustomLog logs/img.aaa.net-access_log common