标签:alt class 子目录 systemctl 文件中 ges 编辑 页面 文件
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 编辑域名解析的配置文件
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、创建并添加域名文档
[root@localhost ~]# vi /var/named/lgl.com.zone
以下是添加域名内容
$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
8、同上理,lby.com的域名配置如下
[root@localhost ~]# vi /var/named/lby.com.zone
$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
9、重启服务
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl restart named
关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
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
1111111111
[root@localhost ~]# mkdir /kkk
[root@localhost ~]# vi /kkk/index.html
222222222
测试
实验以做完,20域名网站自行添加修改即可。此为centos7 httpd域名配置
标签:alt class 子目录 systemctl 文件中 ges 编辑 页面 文件
原文地址:http://www.cnblogs.com/leiguilong/p/6349300.html