【ownCloud】文件夹权限设置详解

Nov. 8, 2016

对于ownCloud目录,为了方便我一直都是粗略地设置为770或650,用户为Apache,现在说一下细致的设置
linux-security

快速设置脚本

以下脚本可以帮助你快速进行设置
#!/bin/bash
ocpath='/var/www/owncloud'
htuser='www-data'
htgroup='www-data'
rootuser='root'

printf “Creating possible missing Directories\n” mkdir -p $ocpath/data mkdir -p $ocpath/assets mkdir -p $ocpath/updater

printf “chmod Files and Directories\n” find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640 find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750

printf “chown Directories\n” chown -R ${rootuser}:${htgroup} ${ocpath}/ chown -R ${htuser}:${htgroup} ${ocpath}/apps/ chown -R ${htuser}:${htgroup} ${ocpath}/assets/ chown -R ${htuser}:${htgroup} ${ocpath}/config/ chown -R ${htuser}:${htgroup} ${ocpath}/data/ chown -R ${htuser}:${htgroup} ${ocpath}/themes/ chown -R ${htuser}:${htgroup} ${ocpath}/updater/

chmod +x ${ocpath}/occ

printf “chmod/chown .htaccess\n” if [ -f ${ocpath}/.htaccess ] then chmod 0644 ${ocpath}/.htaccess chown ${rootuser}:${htgroup} ${ocpath}/.htaccess fi if [ -f ${ocpath}/data/.htaccess ] then chmod 0644 ${ocpath}/data/.htaccess chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess fi

注意:其中的网页服务器用户要按照实际使用的系统更改,参见上文。
将以上内容复制下来,粘到一个文本文件中,保存为permission.sh。执行以下命令:
chmod +x permission.sh
./permission.sh

手动设置的原则

如果上面的脚本不能用,或有特殊需求,可以按照以下原则进行设置。