2011年12月26日 星期一

Apache 建置各使用者網頁

啟動 Apache 模組功能
$sudo a2enmod userdir

a2 : apache2
en : enable
mod : module


修改 xml 設定檔
$sudo nano /etc/apache2/httpd.conf

由於檔案時空的,所以貼上以下內容

UserDir www   

<Directory /home/*/www>
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec


    # If GET is used it will also restrict HEAD requests. The TRACE method cannot be limited.
    <Limit GET POST OPTIONS>
        Order allow,deny
        Allow from all
    </Limit>


    <LimitExcept GET POST OPTIONS>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>

UserDir www                         --表示網頁目錄是在各使用者家目錄的 www 之下

<Directory /home/*/www>     --將設定使用在 home 下的"所有目錄"下的 www


重新啟動 apache2 才會套用設定
$sudo /etc/init.d/apache2 restart

在使用者家目錄下建立網頁,以 student 這使用者為例 :

$cd /home/student                   --切換目錄
    
$mkdir www                             --建立 www 目錄

$nano /www/index.html           --新增首頁並加入內容

內容輸入 : This is a test for student

連線測試,例如主機 IP 為 192.168.1.10,開啟瀏覽器在網址輸入 :
http://192.168.1.10/~student/

有看見剛剛輸入的文字就成功了

沒有留言:

張貼留言