apache绑定多个域名

apache 2.4配置文件 /etc/httpd/conf/httpd.conf

搜了下说要配置NameVirtualHost ,其实根本没必要,建议看下官方文档http://httpd.apache.org/docs/2.4/en/vhosts/name-based.html

我要配置两个域名,分别为btsha.com,piger.cc,直接添加VirtualHost节点信息即可

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
<VirtualHost *:80>
    # This first-listed virtual host is also the default for *:80
    ServerName www.btsha.com
    ServerAlias btsha.com 
    DocumentRoot "/var/www/html"
</VirtualHost>

<VirtualHost *:80>
    ServerName www.piger.cc
    ServerAlias piger.cc
    DocumentRoot "/var/www/h2"
</VirtualHost>
原文地址:https://www.cnblogs.com/pigercc/p/6485580.html