|
配置如下:
[root@csmy ~]# ifconfig eth0 192.168.39.2 netmask 255.255.255.0 up//设置IP地址
[root@csmy named]# rpm -qa|grep httpd//查看apache安装状态
httpd-2.2.3-11.el5_1.3
httpd-manual-2.2.3-11.el5_1.3
[root@csmy ~]# vi /etc/httpd/conf/httpd.conf//编辑httpd.conf
修改内容如下:
Listen 192.168.39.2:80
ServerAdmin csmy@college.edu
ServerName csmywww.college.edu:80
添加虚拟主机:
NameVirtualHost 192.168.39.2:80
<VirtualHost csmywww.college.edu>
ServerAdmin csmy@college.edu
DocumentRoot /var/www/html/csmywww
ServerName csmywww.college.edu
ErrorLog /var/log/httpd/csmywww/error_log
CustomLog /var/log/httpd/csmywww/access_log common
</VirtualHost>
<VirtualHost research.college.edu>
ServerAdmin csmy@college.edu
DocumentRoot /var/www/html/research
ServerName research.college.edu
ErrorLog /var/log/httpd/research/error_log
CustomLog /var/log/httpd/research/access_log common
</VirtualHost>
<VirtualHost office.college.edu>
ServerAdmin csmy@college.edu
DocumentRoot /var/www/html/office
ServerName office.college.edu
ErrorLog /var/log/httpd/office/error_log
CustomLog /var/log/httpd/office/access_log common
</VirtualHost>
<VirtualHost teach.college.edu>
ServerAdmin csmy@college.edu
DocumentRoot /var/www/html/teach
ServerName teach.college.edu
ErrorLog /var/log/httpd/teach/error_log
CustomLog /var/log/httpd/teach/access_log common
</VirtualHost>
[root@csmy ~]# cd /var/www/html///建立网页主页文件夹
[root@csmy html]# ls
[root@csmy html]# mkdir csmywww
[root@csmy html]# mkdir office
[root@csmy html]# mkdir teach
[root@csmy html]# mkdir research
[root@csmy html]# cd csmywww/
[root@csmy csmywww]# vi index.html//编辑主页
[root@csmy csmywww]# cd ..
[root@csmy html]# cd office/
[root@csmy office]# vi index.html//编辑主页
[root@csmy office]# cd ..
[root@csmy html]# cd teach/
[root@csmy teach]# vi index.html//编辑主页
[root@csmy teach]# cd ..
[root@csmy html]# cd research/
[root@csmy research]# vi index.html//编辑主页
[root@csmy research]# cd /var/log/httpd///建立错误日志文件
[root@csmy httpd]# ls
access_log error_log ssl_access_log ssl_error_log.1
access_log.1 error_log.1 ssl_error_log ssl_request_log
[root@csmy httpd]# mkdir csmywww
[root@csmy httpd]# mkdir office
[root@csmy httpd]# mkdir teach
[root@csmy httpd]# mkdir research
[root@csmy httpd]# cp error_log csmywww/
[root@csmy httpd]# cp access_log csmywww/
[root@csmy httpd]# cp error_log office/
[root@csmy httpd]# cp access_log office/
[root@csmy httpd]# cp error_log teach/
[root@csmy httpd]# cp access_log teach/
[root@csmy httpd]# cp error_log research/
[root@csmy httpd]# cp access_log research/
[root@csmy httpd]# cd /etc/ //在DNS里面添加主机和虚拟主机
[root@csmy etc]# vi hosts
192.168.39.2 csmywww.college.edu www
192.168.39.2 office.college.edu www1
192.168.39.2 teach.college.edu www2
192.168.39.2 research.college.edu www3
[root@csmy etc]# vi resolv.conf
nameserver 192.168.39.2
domain college.edu
search college.edu
[root@csmy etc]# vi named.
named.caching-nameserver.conf named.rfc1912.zones
[root@csmy etc]# cp -p named.rfc1912.zones named.conf //CP DNS文件
[root@csmy etc]# vi named.conf
zone "college.edu" IN {
type master;
file "college.edu";
allow-update { none; };
};
zone "113.168.192.in-addr.arpa" IN {
type master;
file "113.168.192";
allow-update { none; };
};
[root@csmy etc]# cd /var/named/chroot/var/named/ //进入正反向解析文件进行编辑
[root@csmy named]# ls
localdomain.zone named.ca named.zero
localhost.zone named.ip6.local slaves
data named.broadcast named.local
[root@csmy named]# cp -p named.local 39.168.192 //CP逆向解析文件
[root@csmy named]# vi 39.168.192 //编辑逆向解析文件
$TTL 86400
@ IN SOA csmywww.college.edu. root.csmywww.college.edu. (
1997022701 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS csmywww.college.edu.
2 IN PTR csmywww.college.edu.
2 IN PTR office.college.edu.
2 IN PTR teach.college.edu.
2 IN PTR research.college.edu.
[root@csmy named]# cp -p localhost.zone college.edu//CP正向解析文件
[root@csmy named]# vi college.edu //编辑正向解析文件
$TTL 86400
@ IN SOA csmywww.college.edu. root.csmywww.college.edu. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS csmywww.college.edu.
IN A 127.0.0.1
IN AAAA ::1
csmywww.college.edu. IN A 192.168.39.2
office.college.edu. IN A 192.168.39.2
teach.college.edu. IN A 192.168.39.2
research.college.edu. IN A 192.168.39.2
[root@csmy named]# /etc/init.d/named restart //重启DNS
停止 named: [确定]
启动 named: [确定]
[root@csmy named]# /etc/init.d/httpd start//启动HTTPD
启动 httpd: [确定]
[root@csmy named]# nslookup //测试解析的域名
> 192.168.39.2
Server: 192.168.39.2
Address: 192.168.39.2#53
2.39.168.192.in-addr.arpa name = teach.college.edu.
2.39.168.192.in-addr.arpa name = office.college.edu.
2.39.168.192.in-addr.arpa name = csmywww.college.edu.
2.39.168.192.in-addr.arpa name = research.college.edu.
> office
Server: 192.168.39.2
Address: 192.168.39.2#53
Name: office.college.edu
Address: 192.168.39.2
> research
Server: 192.168.39.2
Address: 192.168.39.2#53
Name: research.college.edu
Address: 192.168.39.2
> teach
Server: 192.168.39.2
Address: 192.168.39.2#53
Name: teach.college.edu
Address: 192.168.39.2
> exit
[root@csmy named]# |
|