apache配置多域名二级域名
nginx配置多域名泛解析的看这个链接:https://www.cnblogs.com/Crazy-Liu/p/10879740.html
下面直接来操作:
[root@localhost ~]# find / -name httpd.conf ###查找配置文件目录地址 /etc/httpd/conf/httpd.conf [root@localhost ~]# vi /etc/httpd/conf/httpd.conf
编辑这个配置文件直接按组合建shift+G至配置文件最下面这行编辑添加你所需的域名配置。多个域名如此类推
# 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>
重启apache生效
systemctl restart httpd.service
总结:
1.先把你要的二级域名解析到服务器ip。跟www一样解析。
2.找到配置文件添加虚拟主机头配置好目录文件和域名
3.添加的虚拟主机头指定目录新建对应目录文件并上传网站源码
4.重启apache生效
专业从事搬砖多年,还是在继续搬砖中,厚积薄发~