apache配置多域名二级域名

 

nginx配置多域名泛解析的看这个连接:http://www.javashuo.com/article/p-acnnrtxm-dk.htmlhtml

 

下面直接来操做:nginx

[root@localhost ~]# find / -name httpd.conf   ###查找配置文件目录地址
/etc/httpd/conf/httpd.conf
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf

编辑这个配置文件直接按组合建shift+G至配置文件最下面这行编辑添加你所需的域名配置。多个域名如此类推web

# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com 
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

###以上是apache给的示例参考,下面是个人多站点编辑自定义多个域名

<VirtualHost *:80>
    ServerAdmin 838670594@qq.com
    DocumentRoot  /home/www/www.baidu.com
    ServerName  www.baidu.com
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin 838670594@qq.com
    DocumentRoot  /home/www/wiki.baidu.com
    ServerName  wiki.baidu.com
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
httpd.conf

 

重启apache生效apache

systemctl restart httpd.service

 

总结:服务器

1.先把你要的二级域名解析到服务器ip。跟www同样解析。ide

2.找到配置文件添加虚拟主机头配置好目录文件和域名网站

3.添加的虚拟主机头指定目录新建对应目录文件并上传网站源码spa

4.重启apache生效3d

相关文章
相关标签/搜索