企业需求:
一、配置web服务器,能被http://dtop30.dn.ws.com访问
二、配置web服务器,实现虚拟主机。 http://www30.dn.ws.com能访问到/www/virtual目录下的页面,
页面从http://ip/dir/restircted.html下载。
并保证,http://dktop30.dn.ws.com同样能被访问到之前的内容。
三、从http://ip/dir/restircted.html下载文件,能被本地用户sisi通过路径
http://dtop.dn.ws.com/restircted访问到,但是不可以被remote.com域访问。
实施步骤:
一、配置web服务器,能被http://dtop30.dn.ws.com访问
1.安装httpd,并启动服务。 [root@dtop30 ~]# rpm -qa |grep httpd
[root@dtop30 ~]# yum -y install httpd
[root@dtop30 ~]# chkconfig httpd on
[root@dtop30 ~]# service httpd start
2.首先要通读题意:这里最终要创建2个web站点,一个是http://dtop30.dn.ws.com,
还有一个是http://www30.dn.ws.com。所以,2个都必定是虚拟主机!
配置httpd的主配置文件。
[root@dtop30 ~]# vim /etc/httpd/conf/httpd.conf

3.编写web页面。
[root@dtop30 ~]# vim /var/www/html/index.html

4.重启httpd服务。测试:
[root@dtop30 ~]# service httpd restart
[root@dtop30 ~]# elinks http://dtop30.dn.ws.com

ok!
二、配置虚拟主机。 http://www30.dn.ws.com能访问到/www/virtual目录下的页面,
页面从http://ip/dir/restircted.html下载。
并保证,http://dtop30.dn.ws.com同样能被访问到之前的内容。
1.配置httpd主配置文件,添加虚拟主机www30.dn.ws.com。
[root@dtop30 ~]# vim /etc/httpd/conf/httpd.conf

2.创建网页目录,并赋予http类型的context值。
[root@dtop30 ~]# mkdir -p /www/virtual
[root@dtop30 ~]# ls -lZ /var/www/html

[root@dtop30 ~]# semanage fcontext -a -t httpd_sys_content_t ‘/www(/.*)?’
[root@dtop30 ~]# restorecon –vFR /www
3.下载指定内容的页面
[root@dtop30 ~]# cd /www/virtual
[root@dtop30 virtual]#
4.下载网页:http://ip/dir/

右键 restircted.html

Name:index.html
保存位置选择:Browse for other folders —>/www/virtual —>save

5.查看内容,查看context。
[root@dtop30 virtual]# cat index.html
[root@dtop30 virtual]# ls -lZ index.html
6.重启httpd服务。测试 :
[root@dtop30 virtual]# service httpd restart
[root@dtop30 virtual]# elinks http://www30.dn.ws.com

ok!
[root@dtop30 virtual]# elinks http://dtop30.dn.ws.com

ok!
三、从http://ip/dir/restircted.html下载文件,能被本地用户sisi通过路径
http://dtop30.dn.ws.com/restircted访问到,但是不可以被remote.com域访问。
1.创建http用户
[root@dtop30 ~]# htpasswd –cm /etc/httpd/.htpasswd sisi 系统可以不存在此用户
[root@dtop30 ~]# htpasswd –m /etc/httpd/.htpasswd tami 第2个以后的用户,请不要有”-c”
2.站点启用认证:…这部分更验证内容!
[root@dtop30 ~]# vim /etc/httpd/conf/httpd.conf

3.重启httpd。测试!
[root@dtop30 ~]# service httpd restart

输入用户名: sisi 密码:password ok!可以访问到了

4.字符界面测试。3.4.测试任选择一种即可!
[root@dtop30 ~]# links http://www30.dn.ws.com

ok!可以访问到了。