1、[[email protected] ~]# yum -y install http* bind* 首先安装httpd和域名解析软件包2、[[email protected] ~]# vi /etc/httpd/conf/httpd.conf 修改httpd配置文件3、<VirtualHost *:80> DocumentRoot /www ServerName www.lgl.com</VirtualHost> 在配置文件末尾添加虚拟主机,网站根目录和域名自己拟定,20个即可,此处只是一个示例 20个虚拟主机即可
4、[[email protected] ~]# vi /etc/named.conf 编辑域名解析的配置文件5、options { listen-on port 53 { any; }; listen-on-v6 port 53 { any; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; allow-query { any; }; 配置文件这三处都改为any以备所有访问 6、(接下来是域名解析配置,由于咱们为了方便,将其中17个域名头部更改了一下,剩余3个域名将中心也做了更改,所以根据本次配置要求需要做两个中心配置,带颜色处重要)zone "lgl.com." IN { type master; file "lgl.com.zone";};zone "lby.com." IN { type master; file "lby.com.zone";};7、创建并添加域名文档[[email protected] ~]# vi /var/named/lgl.com.zone以下是添加域名内容$TTL 86400lgl.com. IN SOA www.lgl.com. root ( 20160125 1H 1M 1W 1D )lgl.com. IN NS www.lgl.com.www IN A 192.168.209.110kkk IN A 192.168.209.110lll IN A 192.168.209.110jjj IN A 192.168.209.110ggg IN A 192.168.209.110qqq IN A 192.168.209.110eee IN A 192.168.209.110rrr IN A 192.168.209.110ttt IN A 192.168.209.110yyy IN A 192.168.209.110uuu IN A 192.168.209.110iii IN A 192.168.209.110ppp IN A 192.168.209.110aaa IN A 192.168.209.110sss IN A 192.168.209.110ddd IN A 192.168.209.110fff IN A 192.168.209.1108、同上理,lby.com的域名配置如下[[email protected] ~]# vi /var/named/lby.com.zone$TTL 86400lby.com. IN SOA www.lby.com. root ( 2016125 1H 1M 1W 1D )lby.com. IN NS www.lby.com. www IN A 192.168.209.110kkk IN A 192.168.209.110xxx IN A 192.168.209.1109、重启服务[[email protected] ~]# systemctl restart httpd[[email protected] ~]# systemctl restart named关闭防火墙[[email protected] ~]# systemctl stop firewalld[[email protected] ~]# setenforce 010、将配置文件中所有目录都改为 根目录下 以备配置文件查找到虚拟主机网站目录 如:<Directory /> DocumentRoot "/" <Directory "/"> # Further relax access to the default document root: AllowOverride None AllowOverride none <Directory "/"> # Allow open access: Require all denied # Require all granted </Directory> # Possible values for the Options directive are "None", "All",</Directory> 也就是说在centos7中,域名网站根目录必须在配置文件主目录的子目录里才能被找到,不然只会显示httpd页面 11、由于是测试环境,所以咱们就先创建两个网站,利用curl进行测试[[email protected] ~]# mkdir /www[[email protected] ~]# vi /www/index.html1111111111[[email protected] ~]# mkdir /kkk[[email protected] ~]# vi /kkk/index.html222222222 测试实验以做完,20域名网站自行添加修改即可。此为centos7 httpd域名配置
时间: 2024-10-27 18:56:37