上机实践(7)

2018-11-24 19:02

Order allow,deny :访问策略:如果没有明确允许,就拒绝访问 Allow from all :允许所有的访问,这两行都不需修改

(9)DirectoryIndex index.html index.html.var :设置默认文档,可不修改 (10)AddDefaultCharset UTF-8 :设置默认字符集,对于简体中文网页,需要修改为:AddDefaultCharset GB2312

(11)cd /var/www/html(工作目录) (12)vi index.html :添加主页文件,可随意输入内容 (13)service httpd restart :重新启动Apache服务器

(14)从XP访问http://192.168.1.103:8080/,看是否看到刚才编辑的主页文件 (15)重新编辑主配置文件,将监听端口改回80:Listen 192.168.1.103:80 (16)service httpd restart :重新启动Apache服务器

(17)从XP访问http://192.168.1.103:80/,看是否看到刚才编辑的主页文件 3. Apache虚拟目录配置

虚拟目录,就是把某个目录映射为主目录下的一个逻辑目录,本任务目标:创建虚拟目录/down,实际的目录位置在/var/www/html/vd cd /var/www/html mkdir vd cd vd

vi index.html :编辑虚拟目录默认文档,随意输入内容 cd /etc/httpd/conf vi httpd.conf :添加一行:Include conf.vd/*.conf cd ..

mkdir conf.vd cd conf.vd vi vd.conf :输入 Alias /down \service httpd restart

从XP访问http://192.168.1.103/down,看是否看到刚才编辑的虚拟目录主页文件

【实验重点】

1.Apache服务基本配置; 2.Apache虚拟目录配置。

31

Web虚拟主机配置

【实验目的】

掌握Apache基于IP地址、域名的虚拟主机配置。

【实验内容】

1.首先完成Web服务基本配置 2.基于IP地址的虚拟主机 (1)给主机加上两个IP地址: #ifconfig eth0:0 192.168.1.20 #ifconfig eth0:1 192.168.1.21

(2)在配置文件末加上如下内容,具体如下:

#cd /etc/httpd/conf #vi httpd.conf添加如下内容:

ServerName 192.168.16.20:80 ServerAdmin web1@163.com

DocumentRoot \DirectoryIndex index.html ErrorLog logs/web1/error_log

CustomLog logs/web1/access_log combined

ServerName 192.168.16.21:80 ServerAdmin web2@163.com

DocumentRoot \DirectoryIndex default.html ErrorLog logs/web2/error_log

CustomLog logs/web2/access_log combined

(3)添加主页文件:

#mkdir /var/www/html/web1

#vi /var/www/html/web1/index.html #可以输入:this is 192.168.1.20’s webpage #mkdir /var/www/html/web2

#vi /var/www/html/web2/default.html #可以输入:this is 192.168.1.21’s webpage (4)在XP系统中测试两个IP地址的网页。

3.基于域名的虚拟主机

32

Apache虚拟主机配置:准备工作——DNS配置 (1)安装DNS服务器 #rpm –ivh bind-9.3.4-6.P1.el5.i386.rpm #rpm –ivh caching-nameserver-9.3.4-6.P1.el5.i386.rpm (3)配置/etc/named.conf #vi /etc/named.conf #参照DNS配置

(4)配置/etc/named.rfc1912.zones文件,在文件末添加两个域名。 #vi /etc/named.rfc1912.zones 在文件末添加如下内容:

zone \ # 添加的正向解析区

type master;

file \allow-update {none;}; };

zone \ # 添加的方向解析区

type master;

file \allow-update {none;}; };

zone \ # 添加的正向解析区

type master;

file \allow-update {none;}; };

zone \ # 添加的方向解析区

type master;

file \allow-update {none;}; };

(5)配置区域配置文件:/var/named/目录下配置:

a)建立jun.com.zone,如下:

$TTL 86400 @ IN SOA dns.jun.com. root.jun.com. ( 2009052200 ;serial 28800 ;refresh 14400 ;retry 720000 ;expire 86400 ;ttl )

@ IN NS dns.jun.com. dns IN A 192.168.1.200 www IN A 192.168.1.200

33

b)建立liu.com.zone,如下: $TTL 86400 @ IN SOA dns.liu.com. root.jun.com. ( 2009052200 ;serial 28800 ;refresh 14400 ;retry 720000 ;expire 86400 ;ttl )

@ IN NS dns.liu.com. dns IN A 192.168.1.200 www IN A 192.168.1.200 c)编辑反向解析区域(可以不配置)

(6)在XP系统中测试www.liu.com及www.jun.com域名 (7)在/etc/httpd.conf配置文件末加上如下内容,具体如下:

#cd /etc/httpd/conf #vi httpd.conf添加如下内容:

ServerName www.jun.com ServerAdmin web1@jun.com

DocumentRoot \DirectoryIndex index.html ErrorLog logs/web1/error_log

CustomLog logs/web1/access_log combined

ServerName www.liu.com ServerAdmin web2@liu.com

DocumentRoot \DirectoryIndex index.html ErrorLog logs/web2/error_log

CustomLog logs/web2/access_log combined

和:将更正为::NameVirtualHost 192.168.1.200:80 (3)添加主页文件:

#mkdir /var/www/html/jun.com

#echo “this is jun.com’s webpage “> /var/www/html/jun.com/index.html #mkdir /var/www/html/liu.com

# echo “this is liu.com’s webpage “> /var/www/html/liu.com/index.html (4)在XP系统中测试两个域名的网页(DNS配置要指向DNS服务器)。 34

【实验重点】

Apache基于IP及域名的虚拟主机配置。

35


上机实践(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2014年一建工程法规总结

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: