瀏覽器顯示 403 Forbidden: You don't have permission to access / on this server,核心原因通常是 Apache 存取控制與目錄索引設定不當。
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all # 預設為 Deny from all,改為 Allow
Satisfy all
</Directory>
Order deny,allow 配合 Allow from all 表示「先檢查 deny,無匹配則允許」。預設 Deny from all 會封鎖所有請求。
Apache 預設尋找 DirectoryIndex index.html。若目錄無索引檔且未啟用 Options Indexes,將回傳 403。
<IfModule dir_module>
DirectoryIndex index.html index.php index.jsp
</IfModule>
Options Indexes FollowSymLinks
加入 Indexes 允許使用者瀏覽目錄列表。
即使 Apache 允許,若 Linux 檔案權限為 700 或擁有者非 apache/www-data,仍會 403。執行:
chown -R apache:apache /var/www/html
chmod -R 755 /var/www/html
依序驗證:Apache 設定 → 索引檔 → 檔案權限,即可徹底消除 403。