2011-01-22 237 views
4

我有一個craptastic時間試圖找出我應該如何配置我的Drupal文件夾和文件。我已經在drupal.org上搜索了所有內容,但不斷地提出關於需要訪問「網站」和「文件」文件夾的www數據以及「settings.php」如何需要一些令人敬畏的權限的運行。Drupal文件夾和文件權限

但我需要的是像這樣的列表:

/= 744或drwxr-R--
/包括/ = ...
/其它/ = ...
/模塊/ = ...
/型材/ = ...
/腳本/ = ...
/網站/ = ...
/網站/所有/ = ...
/網站/默認/ = ...
/sites/default/s ettings.php = 444?
/sites/default/files/= ...

我不認爲我需要某人爲我編制每一個文件,文件夾和權限設置。我猜測我可以將根文件夾權限設置爲「適用於封閉項目」,然後修復需要特殊設置的幾個文件夾和文件。

我真的很感激任何可以讓我回到理智的貢獻! :)

斯科特

+0

最好向谷歌尋求有關Drupal的答案,因爲現在,你最終在Stackoverflow。 +1每個問題和答案。 – Diogenes 2011-03-14 15:13:43

回答

5

默認安裝在我的本地機器上有

-RW-R - R--所有PHP文件

drwxr-XR-X目錄

drwxrwxr- x文件夾

-r - r - r-- settings.php文件

+0

感謝您花時間查看您的設置並回報。這些爲我工作。 – skhot 2011-01-23 00:34:01

2

我的回覆已經很晚了,但我遇到了這個問題並找到了解決辦法。 從Drupal's official handbook

拷貝到一個文件,並將其命名爲 「fix-permissions.sh」

#!/bin/bash 
if [ $(id -u) != 0 ]; then 
     printf "This script must be run as root.\n" 
     exit 1 
fi 
drupal_path=${1%/} 
drupal_user=${2} 
httpd_group="${3:-www-data}" 
# Help menu 
print_help() { 
cat <<-HELP 
This script is used to fix permissions of a Drupal installation 
you need to provide the following arguments: 
1) Path to your Drupal installation. 
2) Username of the user that you want to give files/directories ownership. 
3) HTTPD group name (defaults to www-data for Apache). 
Usage: (sudo) bash ${0##*/} --drupal_path=PATH --drupal_user=USER --httpd_group=GROUP 
Example: (sudo) bash ${0##*/} --drupal_path=/usr/local/apache2/htdocs --drupal_user=john --httpd_group=www-data 
HELP 
exit 0 
} 
# Parse Command Line Arguments 
while [ $# -gt 0 ]; do 
     case "$1" in 
       --drupal_path=*) 
drupal_path="${1#*=}" 
;; 
--drupal_user=*) 
drupal_user="${1#*=}" 
;; 
--httpd_group=*) 
httpd_group="${1#*=}" 
;; 
--help) print_help;; 
*) 
printf "Invalid argument, run --help for valid arguments.\n"; 
exit 1 
esac 
shift 
done 
if [ -z "${drupal_path}" ] || [ ! -d "${drupal_path}/sites" ] || [ ! -f "${drupal_path}/core/modules/system/system.module" ] && [ ! -f "${drupal_path}/modules/system/system.module" ]; then 
printf "Please provide a valid Drupal path.\n" 
print_help 
exit 1 
fi 
if [ -z "${drupal_user}" ] || [ $(id -un ${drupal_user} 2> /dev/null) != "${drupal_user}" ]; then 
printf "Please provide a valid user.\n" 
print_help 
exit 1 
fi 
cd $drupal_path 
printf "Changing ownership of all contents of "${drupal_path}":\n user => "${drupal_user}" \t group => "${httpd_group}"\n" 
chown -R ${drupal_user}:${httpd_group} . 
printf "Changing permissions of all directories inside "${drupal_path}" to "rwxr-x---"...\n" 
find . -type d -exec chmod u=rwx,g=rx,o= '{}' \; 
printf "Changing permissions of all files inside "${drupal_path}" to "rw-r-----"...\n" 
find . -type f -exec chmod u=rw,g=r,o= '{}' \; 
printf "Changing permissions of "files" directories in "${drupal_path}/sites" to "rwxrwx---"...\n" 
cd sites 
find . -type d -name files -exec chmod ug=rwx,o= '{}' \; 
printf "Changing permissions of all files inside all "files" directories in "${drupal_path}/sites" to "rw-rw----"...\n" 
printf "Changing permissions of all directories inside all "files" directories in "${drupal_path}/sites" to "rwxrwx---"...\n" 
for x in ./*/files; do 
find ${x} -type d -exec chmod ug=rwx,o= '{}' \; 
find ${x} -type f -exec chmod ug=rw,o= '{}' \; 
done 
echo "Done settings proper permissions on files and directories" 

現在運行該腳本:

中提琴!您的權限會自動修復。

+0

謝謝!這爲我節省了很多工作。 – 2014-08-20 19:06:15