以下是 WordPress 建議的標準檔案權限設定方式,適合大多數主機環境使用。
一、整個網站權限
# 設定資料夾
find /你的wordpress路徑/ -type d -exec chmod 755 {} \;
# 設定檔案
find /你的wordpress路徑/ -type f -exec chmod 644 {} \;
二、uploads 資料夾
find wp-content/uploads -type d -exec chmod 755 {} \;
find wp-content/uploads -type f -exec chmod 644 {} \;
三、wp-config.php
chmod 600 wp-config.php
或:
chmod 640 wp-config.php
四、檔案擁有者
確認網站檔案擁有者正確,例如:
chown -R www-data:www-data /你的wordpress路徑/
(依主機環境調整使用者名稱)
五、建議安全設定
在 wp-content/uploads 新增 .htaccess:
<Files *.php>
deny from all
</Files>
以上為 WordPress 常見且建議的標準權限設定方式。