假如你的 Server 會建立不同的用戶,你會想限制用戶只能有權限看自己的文檔,普遍做法是每個用戶都有自己的Home Directory,通常是 /home/username/public_html。

這個網頁的步驟簡單而清晰,可以參考
http://centosforge.com/node/how-get-userdir-user-specific-publichtml-working-apache-centos-6

1. 開啟Apache Config File

[super_user_name@server ~]$ sudo vi /etc/httpd/conf/httpd.conf

 

2. 尋找「IfModule mod_userdir」,並修改如下

<IfModule mod_userdir.c>
 #
 # UserDir is disabled by default since it can confirm the presence
 # of a username on the system (depending on home directory
 # permissions).
 #
 #UserDir disabled
 UserDir "enabled *"
 UserDir "disabled root"
 #
 # To enable requests to /~user/ to serve the user's public_html
 # directory, remove the "UserDir disabled" line above, and uncomment
 # the following line instead:
 #
 UserDir public_html
 </IfModule>

 

3. 重新啟動Apache

[super_user_name@server ~]$ sudo service httpd restart

 

4. 設置Permission

[super_user_name@server ~]$ sudo chmod 711 /home
[super_user_name@server ~]$ sudo chmod 711 /home/username
[super_user_name@server ~]$ sudo chmod 755 /home/username/public_html