1、
[root@localhost ~]# yum -y install http* bind* 首先安装httpd和域名解析软件包
2、
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf 修改httpd配置文件
3、
<VirtualHost *:80>
DocumentRoot /www
ServerName www.lgl.com
</VirtualHost> 在配置文件末尾添加虚拟主机,网站根目录和域名自己拟定,20个即可,此处只是一个示例![]()
20个虚拟主机即可
4、
[root@localhost ~]# vi /etc/named.conf 编辑域名解析的配置文件
![centos7服务器运行20个网站插图4](https://images2015.cnblogs.com/blog/1096705/201701/1096705-20170125110540972-1589836325.png)
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以备所有访问
![centos7服务器运行20个网站插图5 centos7服务器运行20个网站插图5](https://www.moluyao.wang/wp-content/uploads/2024/01/unnamed-file-1628.png)
6、
(接下来是域名解析配置,由于咱们为了方便,将其中17个域名头部更改了一下,剩余3个域名将中心也做了更改,所以根据本次配置要求需要做两个中心配置,带颜色处重要)
zone "lgl.com." IN {
type master;
file "lgl.com.zone";
};
zone "lby.com." IN {
type master;
file "lby.com.zone";
};
![centos7服务器运行20个网站插图6 centos7服务器运行20个网站插图6](https://www.moluyao.wang/wp-content/uploads/2024/01/unnamed-file-1629.png)
7、创建并添加域名文档
[root@localhost ~]# vi /var/named/lgl.com.zone
![centos7服务器运行20个网站插图7](https://images2015.cnblogs.com/blog/1096705/201701/1096705-20170125111936847-452851186.png)
以下是添加域名内容
$TTL 86400
lgl.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.110
kkk IN A 192.168.209.110
lll IN A 192.168.209.110
jjj IN A 192.168.209.110
ggg IN A 192.168.209.110
qqq IN A 192.168.209.110
eee IN A 192.168.209.110
rrr IN A 192.168.209.110
ttt IN A 192.168.209.110
yyy IN A 192.168.209.110
uuu IN A 192.168.209.110
iii IN A 192.168.209.110
ppp IN A 192.168.209.110
aaa IN A 192.168.209.110
sss IN A 192.168.209.110
ddd IN A 192.168.209.110
fff IN A 192.168.209.110
![centos7服务器运行20个网站插图8 centos7服务器运行20个网站插图8](https://www.moluyao.wang/wp-content/uploads/2024/01/unnamed-file-1630.png)
8、同上理,lby.com的域名配置如下
[root@localhost ~]# vi /var/named/lby.com.zone
![centos7服务器运行20个网站插图9](https://images2015.cnblogs.com/blog/1096705/201701/1096705-20170125112941862-1790464776.png)
$TTL 86400
lby.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.110
kkk IN A 192.168.209.110
xxx IN A 192.168.209.110
![centos7服务器运行20个网站插图10 centos7服务器运行20个网站插图10](https://www.moluyao.wang/wp-content/uploads/2024/01/unnamed-file-1631.png)
9、重启服务
[root@localhost ~]# systemctl restart httpd
![centos7服务器运行20个网站插图11](https://images2015.cnblogs.com/blog/1096705/201701/1096705-20170125113504550-818731741.png)
[root@localhost ~]# systemctl restart named
![centos7服务器运行20个网站插图12 centos7服务器运行20个网站插图12](https://www.moluyao.wang/wp-content/uploads/2024/01/unnamed-file-1632.png)
关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
![centos7服务器运行20个网站插图13](https://images2015.cnblogs.com/blog/1096705/201701/1096705-20170125113914909-647522569.png)
10、
将配置文件中所有目录都改为 根目录下 以备配置文件查找到虚拟主机网站目录 如:
<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进行测试
[root@localhost ~]# mkdir /www
[root@localhost ~]# vi /www/index.html
![centos7服务器运行20个网站插图15 centos7服务器运行20个网站插图15](https://www.moluyao.wang/wp-content/uploads/2024/01/unnamed-file-1634.png)
1111111111
![centos7服务器运行20个网站插图16 centos7服务器运行20个网站插图16](https://www.moluyao.wang/wp-content/uploads/2024/01/unnamed-file-1635.png)
[root@localhost ~]# mkdir /kkk
[root@localhost ~]# vi /kkk/index.html
![centos7服务器运行20个网站插图17 centos7服务器运行20个网站插图17](https://www.moluyao.wang/wp-content/uploads/2024/01/unnamed-file-1636.png)
222222222
![centos7服务器运行20个网站插图18 centos7服务器运行20个网站插图18](https://www.moluyao.wang/wp-content/uploads/2024/01/unnamed-file-1637.png)
测试
实验以做完,20域名网站自行添加修改即可。此为centos7 httpd域名配置
原文链接:https://www.cnblogs.com/leiguilong/p/6349300.html
© 版权声明
声明📢本站内容均来自互联网,归原创作者所有,如有侵权必删除。
本站文章皆由CC-4.0协议发布,如无来源则为原创,转载请注明出处。
THE END