2007/07/06

Apache2 小筆記

啟動Apache server
sudo /etc/init.d/apache2 start

停止Apache server
sudo /etc/init.d/apache2 stop
or
sudo service apache2 restart

重啟動Apache server
sudo /etc/init.d/apache2 restart

使系統上所有使用者都擁有自己的個人網頁
cd /etc/apache2/mod-enabled/
ln -s ../mods-available/userdir.conf userdir.conf
ln-s ../mods-available/userdir.load userdir.load


當使用者瀏覽頁面失敗時,不顯示檔案結構的設定,而出現


Forbidden


You don't have permission to access / on this server.

-----------------------------------------------------------------------------

sudo vim /etc/apache2/sites-avaiable/default

將原指令
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
改成
<Directory /var/www>
Options -Indexes FollowSymLinks MultiViews

系統上的使用者則是
sudo vim /etc/apache2/mods-available/userdir.conf

將原指令
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
</Directory>
改成
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews -Indexes SymLinksIfOwnerMatch IncludesNoExec
</Directory>



網頁希望只讓特定的人瀏覽


在想要保護的目錄下
寫一個.htaccess
內容為
AuthName "Hi, there."
AuthUserFile [passwd path]/.passwd
AuthType Basic
require valid-user

創建具瀏覽權限的名單 .passwd htpasswd -c [passwd path]/.passwd username (第一次建立.passwd)
htpasswd [passed path]/.passwd username (新增其它具有權限瀏覽的user)


2 comments:

  1. To let users construct web pages in their home directories, you can use "a2enmod userdir" instead of making symbolic links by yourself to accomplish the goal. :)

    ReplyDelete
  2. Thanks for the trick. :)

    ReplyDelete