Apache是目前使用的比较多的Http服务器之一,快速,稳定,可靠,并且可通过简单的API扩展,Perl/Python解释器可被编译到服务器中,完全免费,并且源代码全部开放。如何通过设置Apache的http.conf文件,进行多个域名的绑定呢?
我这里以系统为Centos6.4,IP为112.124.101.177,域名为www.aaa.com,www.bbb.com为例
打开httpd.conf文件
ServerName 127.0.0.1 修改成ServerName 112.124.101.177
#NameVirtualHost * 修改成”NameVirtualHost 112.124.101.177
vi /etc/httpd/conf/httpd.conf
#<VirtualHost *>
# ServerAdmin admin@aaa.com
# DocumentRoot /www/httpd/html/aaa.com
# ServerName aaa.com
# ErrorLog logs/aaa.com-error_log
# CustomLog logs/aaa.com-access_log common
#</VirtualHost>
#<VirtualHost 112.124.101.177>
DocumentRoot usr/local/www/
ServerName 112.124.101.177
#</VirtualHost>
#<VirtualHost 112.124.101.177>
DocumentRoot usr/local/www/aaa.com/
ServerName aaa.com
#</VirtualHost>
#<VirtualHost 112.124.101.177>
DocumentRoot usr/local/www/bbb.com/
ServerName bbb.com
#</VirtualHost>
重启Apache,生效
service httpd restart
用新绑定的域名,访问试试。
原文地址:http://mingkrcom.blog.51cto.com/9039685/1539637