需要一些設定 Apache 使用者目錄的協助

需要一些設定 Apache 使用者目錄的協助

我想讓 Apache 提供 中的“普通”文件/srv/http/public,以及 中的用戶文件/srv/http/[user],因此目錄可能看起來像

/srv/http
  /public
    index.html - Accessible at localhost/index.html
  /austin
    index.html - Accessible at localhost/~austin/index.html

現在,我在Apache.conf檔案中有以下相關配置

User http
Group http
DocumentRoot "/srv/http/public"

<Directory "/srv/http/public">
  Options Indexes FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>

UserDir /srv/http
UserDir disabled root

<Directory "/srv/http">
  AllowOverride FileInfo AuthConfig Limit Indexes
  Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
  <Limit GET POST OPTIONS>
    Order allow,deny
    Allow from all
  </Limit>
  <LimitExcept GET POST OPTIONS>
    Order deny,allow
    Deny from all
  </LimitExcept>
</Directory>

以及以下權限/srv/http

drwxr-xr-x  root    http   /srv/http
drwxr-xr-x  http    http   /srv/http/public
-rwxr-xr-x  http    http   /srv/http/public/index.html
drwxr-xr-x  austin  http   /srv/http/austin
-rwxr-xr-x  austin  http   /srv/http/austin/index.html

使用此設置,localhost/index.html顯示良好,但localhost/~austin/index.html 給出了403 禁止訪問!錯誤,無論我怎麼嘗試。

編輯:相關的error_log條目: [error] [client ::1] client denied by server configuration: /srv/http/austin/index.html

我究竟做錯了什麼?

哦,我認為這並不重要,但我正在使用 Arch Linux 和 Apache 2.2.19

答案1

問題是<Directory>使用者目錄的指令限制太多。

重新使用/srv/http/public目錄中的相同指令允許外界查看任何使用者檔案:

<Directory "/srv/http">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

相關內容