2011-01-22 2 views
4

У меня время от времени пытаться выяснить, как мне настроить папки и файлы Drupal. Я ищу по всему drupal.org, но продолжаю придумывать данные о том, что www-данные нуждаются в доступе к папкам «сайты» и «файлы» и как «settings.php» нуждается в некоторых потрясающих разрешениях.Доступ к папке и файлу Drupal

Но что мне нужно, это список, как это:

/= 744 или drwxr-r--
/включает/= ...
/разное/= ...
/модули/= ...
/профили/= ...
/скрипты/= ...
/сайтов/= ...
/сайты/все/= ...
/сайты/по умолчанию/= ...
/sites/default/s ettings.php = 444?
/sites/default/files/= ...

Я не думаю, что мне нужен кто-то, чтобы каталогизировать каждый файл, папку и настройки разрешений для меня. Я предполагаю, что я могу просто установить права корневой папки «применить к закрытым элементам», а затем исправить несколько папок и файлов, требующих специальных настроек.

Я бы очень признателен за любые вклады, которые могут привести меня к здравому смыслу! :)

Скотт

+0

Лучшее в Google для получения ответов о Drupal, потому что теперь вы оказываетесь в Stackoverflow. +1 для каждого вопроса и ответа. – Diogenes

ответ

5

установки по умолчанию на моей локальной машине имеет

-rw-р - r-- все PHP файлы

drwxr-хт-х каталогов

drwxrwxr- х файлов папки

-r - г - r-- settings.php файл

+0

Спасибо, что нашли время, чтобы посмотреть ваши настройки и отчитаться. Они работали на меня. – skhot

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" 

Теперь запустите этот сценарий как:

Viola! Ваши разрешения автоматически фиксируются.

+0

Спасибо! Это сэкономило мне много работы. –

+0

Большое спасибо. Полезная ссылка и отличный скрипт. – Francisco

Смежные вопросы