apache多网站对应80端口

一台服务器绑定多个域名,已经装了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也可以实现,做个小笔记。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章