配置Apathe服务器

一、实验的目的:
    实现Apathe部署WEB项目,学会处理多个网站之间互相工作,实现主机托管
    给网页添加访问权限


二、实验过程(学生补充完整的细节并作简要的解释)


(一)准备
1、检查httpd 是否安装


    [root@localhost root]# rpm -qa | grep httpd
    httpd-manual-2.0.40-21
    httpd-2.0.40-21
    
    证明 已经安装了


2、检查httpd 是否已启动
     方法一:
    [root@localhost root]# ps -ax | grep httpd
    10958 ?        S      0:00 /usr/sbin/0httpd
    11086 ?        S      0:00 [httpd]
    11087 ?        S      0:00 [httpd]
    11088 ?        S      0:00 [httpd]
    11089 ?        S      0:00 [httpd]
    11090 ?        S      0:00 [httpd]
    11091 ?        S      0:00 [httpd]
    11092 ?        S      0:00 [httpd]
    11093 ?        S      0:00 [httpd]
    11342 pts/0    S      0:00 grep httpd


    方法二
    [root@localhost root]# chkconfig --list httpd
     httpd           0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
  
     证明已经启动


(二)设置缺省字符集
1、编辑主配置文件,设置缺省字符集为 utf-8


       [root@localhost root]# vi /etc/httpd/conf/httpd.conf
       按:进入命令行 输入/AddDefau
       修改为AddDefaultCharset utf-8


2、重启 httpd
       [root@localhost conf]# service httpd restart
       停止 httpd:                                               [  确定  ]
       启动 httpd:                                               [  确定  ]


3、设计缺省主页 index.html,含中文。




       [root@localhost root]# cd /var/www/html
       [root@localhost html]# vi index.html
       这是index主页
        正文1
        正文2


4、window 浏览器测试
http://192.168.233.3
看能否显示中文


       这是index主页 正文1 正文2


       显示中文


(三)允许局部配置,默认不允许 /var/www/html 下的目录索引


       [root@localhost html]# vi /etc/httpd/conf/httpd.conf


       :/AllowOverride 查找 ,按“N”查找下一个找到其中 <Directory "var/www/html">
       将下面的二个修改如下:
       Options -Indexes FollowSymLinks  (不允许目录索引)
       AllowOverride All                (允许局部配置)


       重启 httpd
       [root@localhost conf]# service httpd restart
       停止 httpd:                                               [  确定  ]
       启动 httpd:                                               [  确定  ]


(四)在/var/www/html 下创建目录 lab,局部允许目录索引


       1、在/var/www/html 下创建目录 lab,并创建11.txx
       [root@localhost conf]# cd /var/www/html
       [root@localhost html]# mkdir lab
       [root@localhost lab]# cat 11.txt
       lab
       assd
       第卫星


       2、局部允许目录索引       
       [root@localhost lab]# cat > .htaccess
        Options Indexes
       
       3、验证成果
       在浏览器中输入http://192.168.177.3/lab/,可以看到
       Index of /lab


       Icon  Name                    Last modified      Size  Description
       [DIR] Parent Directory                             -   
       [TXT] 11.txt                  02- 4月-2015 14:46   19   


(五)个人主页
1、编辑主配置文件,注解掉
UserDir disable


去掉注解
UserDir public_html
重启 httpd。




        [root@localhost lab]# vi /etc/httpd/conf/httpd.conf
        按:,输入 /User 搜索,修改如下
        # UserDir disable
        UserDir public_html
        root@localhost conf]# service httpd restart
       停止 httpd:                                               [  确定  ]
       启动 httpd:                                               [  确定  ]


2、用户 yanji 建立个人主页,给相关目录添加适当的权限


       [root@localhost root]# su - yanji
       [yanji@localhost yanji]$ zh
       [yanji@localhost yanji]$ mkdir public_html
       [yanji@localhost yanji]$ cd  public_html
       [yanji@localhost public_html]$ cat > index.html
       <h1>
        yanj主页
        </h1>


        加权限  
       [yanji@localhost public_html]$ chmod 701 .
       [yanji@localhost yanji]$ chmod 701 .


3、Windows 浏览器访问 yanji 的个人主页。
        
       在浏览器输入http://192.168.177.3/~yanji 


三、实验的体会


比较有趣,适合使用。实践起来还是要看书,步骤容易出错
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章