配置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 


三、實驗的體會


比較有趣,適合使用。實踐起來還是要看書,步驟容易出錯
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章