Linux网络服务之HTTP(1)
2014-05-03 10:24
459 查看
Linux网络服务之HTTP(1)
实验要求:
1、主机名设为:www.zhy.com,默认首页包括:index.html、index.php,开启保持连接,确认默认httpd是否支持php
2、只允许192.168.1.1访问www.zhy.com,允许所有用户访问www.zhy.com/user/index.html
3、客户端访问/var/www/html/admin/需要输入用户名密码验证
4、客户端访问http://www.zhy.com/bbs时可以访问/var/www/html/user/bbs下的网页
实验步骤:
1、安装软件包
搭建http服务需要安装软件包httpd
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# vim /var/www/html/index.html //准备访问界面
前提需配置DNS为网站做域名解析
2、修改配置文件
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf //修改http服务主配置文件
……
74 KeepAlive On //开启保持连接功能
……
265 ServerName www.zhy.com //设置域名
……
281 DocumentRoot "/var/www/html" //网站默认根目录
……
306 <Directory "/var/www/html">
……
332 Order allow,deny
333 # Allow from all //默认允许所有人访问,此处注释掉
334 Allow from 192.168.1.1 //只允许该IP地址访问
……
</Directory>
336 <Directory "/var/www/html/user"> //设置对该目录的访问控制
337 Order allow,deny
338 Allow from all //允许所有人访问
339 </Directory>
340 <Directory "/var/www/html/admin">
341 Order allow,deny //先允许,后拒绝,默认拒绝所有
342 Allow from all
343 AuthName "Please Input Password" //弹窗提示
344 AuthType Basic //认证类型
345 AuthUserFile "/etc/httpd/.vuser" //认证文件
346 Require valid-user //指定授权用户或组
347 </Directory>
348 Alias /bbs/ "/var/www/html/bbs" //设置别名
……
391 DirectoryIndex index.html index.php //默认主页文件
……
[root@localhost ~]# htpasswd -c /etc/httpd/.vuser admin //创建认证用户
New password: //创建密码
Re-type new password:
Adding password for user admin
3、启动服务,设置服务开机自动启动
[root@localhost ~]# service httpd restart
停止 httpd: [确定]
启动 httpd: [确定]
[root@localhost ~]# chkconfig httpd on
4、测试
实验要求:
1、主机名设为:www.zhy.com,默认首页包括:index.html、index.php,开启保持连接,确认默认httpd是否支持php
2、只允许192.168.1.1访问www.zhy.com,允许所有用户访问www.zhy.com/user/index.html
3、客户端访问/var/www/html/admin/需要输入用户名密码验证
4、客户端访问http://www.zhy.com/bbs时可以访问/var/www/html/user/bbs下的网页
实验步骤:
1、安装软件包
搭建http服务需要安装软件包httpd
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# vim /var/www/html/index.html //准备访问界面
前提需配置DNS为网站做域名解析
2、修改配置文件
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf //修改http服务主配置文件
……
74 KeepAlive On //开启保持连接功能
……
265 ServerName www.zhy.com //设置域名
……
281 DocumentRoot "/var/www/html" //网站默认根目录
……
306 <Directory "/var/www/html">
……
332 Order allow,deny
333 # Allow from all //默认允许所有人访问,此处注释掉
334 Allow from 192.168.1.1 //只允许该IP地址访问
……
</Directory>
336 <Directory "/var/www/html/user"> //设置对该目录的访问控制
337 Order allow,deny
338 Allow from all //允许所有人访问
339 </Directory>
340 <Directory "/var/www/html/admin">
341 Order allow,deny //先允许,后拒绝,默认拒绝所有
342 Allow from all
343 AuthName "Please Input Password" //弹窗提示
344 AuthType Basic //认证类型
345 AuthUserFile "/etc/httpd/.vuser" //认证文件
346 Require valid-user //指定授权用户或组
347 </Directory>
348 Alias /bbs/ "/var/www/html/bbs" //设置别名
……
391 DirectoryIndex index.html index.php //默认主页文件
……
[root@localhost ~]# htpasswd -c /etc/httpd/.vuser admin //创建认证用户
New password: //创建密码
Re-type new password:
Adding password for user admin
3、启动服务,设置服务开机自动启动
[root@localhost ~]# service httpd restart
停止 httpd: [确定]
启动 httpd: [确定]
[root@localhost ~]# chkconfig httpd on
4、测试
相关文章推荐
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)
- Linux 信号signal处理机制
- linux下mysql添加用户
- Scientific Linux 5.5 图形安装教程
- 基于 Linux 集群环境上 GPFS 的问题诊断
- 谁是桌面王者?Win PK Linux三大镇山之宝
- vivi下重新调整分区
- Linux VS Unix:Linux欲一统天下 Unix不死
- linux下设定环境变量
- Linux下修改MySQL编码的方法