標籤:alt class 子目錄 systemctl 檔案中 ges 編輯 頁面 檔案
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 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的網域名稱配置如下
[[email protected] ~]# 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、重啟服務
[[email protected] ~]# systemctl restart httpd
[[email protected] ~]# systemctl restart named
關閉防火牆
[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# 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進行測試
[[email protected] ~]# mkdir /www
[[email protected] ~]# vi /www/index.html
1111111111
[[email protected] ~]# mkdir /kkk
[[email protected] ~]# vi /kkk/index.html
222222222
測試
實驗以做完,20網域名稱網站自行添加修改即可。此為centos7 httpd網域名稱配置
centos7伺服器運行20個網站