首页 > 代码库 > HTTPD

HTTPD

实验1配置HTTPD

     实验环境

在虚拟机Linux 6.5系统下需要2台Linux系统一台A作为服务端一条B作为测试客户端win7真实主机开启2台Linux系统。

 

     实验目标

         A作为服务端配置VSFTPD服务器实现FTP服务。

         B作为测试客户端验证服务器A的共享是否有效。

         配置真实主机确保真实主机能ping通2台虚拟机。

     实验步骤

1.  首先将A,B真实主机放到同一网段中为了以后实验方便配置永久起效的静态IP地址验证AB真实主机能否通信安装HTTPD服务并启动。

[root@s5 ~]#cd/etc/httpd/conf/

[root@s5 conf]#cphttpd.conf httpd.conf.gz//备份主配置文件

[root@s5conf]#vim httpd.conf

ServerNames5.tarena.com

[root@s5~]#/etc/init.d/httpd restart //重启服务

 

2.  部署网页文档

[root@s5 ~]#cd/var/www/html/

 [root@s5 html]#vim index.html

Hello World !

3.  浏览器访问禁止使用符号链接>配置文件并且当主页不存在时报出错误。

在Win7浏览器上输入http://192.168.1.1查看显示信息

[root@s5conf]#vim httpd.conf

<Directory/>

 304    Options –FollowSymLinks //禁止符号链接

 305    AllowOverride None

 306 </Directory>

[root@s5conf]#vim ../conf.d/welcome.conf //子配置文件

     Options Indexes //当主页不存在时报出错误

4.  使用目录别名

[root@s5conf]#vim httpd.conf

Alias /doc/"/var/www/dev/" //为www下子目录设置别名在浏览器上直接输入地址+/doc/ 直接访问。

 [root@s5 www]#/etc/init.d/httpd restart

http//192.168.1.1/doc/

5.  为指定目录启用用户授权

     1在网站根目录下建一个子目录studir

    能访问 http://服务器地址/studir/

2给studir添加用户授权只允许用户stu01访问密码123456

[root@s5 桌面]#cd /var/www/html/

 [root@s5 html]#mkdir studir //创建目录

[root@s5 html]#htpasswd -c/etc/httpd/authpwd stu01

//添加访问用户当添加第二个用户时若不想覆盖原来的用户不需加-c若覆盖加上-c

New password:

Re-type new password:

Adding password foruser stu01

[root@s5 conf]#vimhttpd.conf

<Directory"var/www/html/studir">

      AuthName"Tarena Library."

      AuthType basic

      AuthUserFile /etc/httpd/authpwd

      Require valid-user

      #Require user stu01

 </Directory>


HTTPD