owncloud权限设置
in Owncloud with 0 comment

owncloud权限设置

in Owncloud with 0 comment

简介

因为权限问题出过各种各样的BUG。官方文档写的很清楚,甚至连脚本都给好了。

官方文档相关参考

Setting Strong Directory Permissions

For hardened security we recommend setting the permissions on your
ownCloud directories as strictly as possible, and for proper server

  1. This should be done immediately after the initial
  2. and before running the setup. Your HTTP user must own the

config/, data/ and apps/ directories so that you can configure
ownCloud, create, modify and delete your data files, and install apps
via the ownCloud Web interface.

You can find your HTTP user in your HTTP server configuration files.
Or you can use PHP Version and Information (Look for the User/Group
line). • The HTTP user and group in Debian/Ubuntu is www-data. • The
HTTP user and group in Fedora/CentOS is apache. • The HTTP user and
group in Arch Linux is http. • The HTTP user in openSUSE is wwwrun,
and the HTTP group is www.


Note: When using an NFS mount for the data directory, do not change
its ownership from the default. The simple act of mounting the drive
will set proper permissions for ownCloud to write to the directory.
Changing ownership as above could result in some issues if the NFS
mount is lost.


步骤

查看用户组和用户名

APACHE:
Debian/Ubuntu 通常为 www-data.
Fedora/CentOS 通常为 apache.
Arch Linux 通常为 http.
openSUSE 的HTTP用户名通常为 wwwrun, 用户组通常为 www.

nginx:
通常为www或nginx

要么就去/etc/passwd里找一下,反正跑不了www或http或apache或nginx这几种。

脚本

知道用户组和用户名就好办了,owncloud 提供了脚本帮助完成权限的设置。

#!/bin/bash
ocpath='此处修改为你owncloud网站根目录的绝对路径'
htuser='此处填写你的http用户名如:www-data'
htgroup='此处填你的http用户组如: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

服务器中创建一个oc-auth.sh文件,将上述代码粘贴进去,然后保存,命令行sudo sh oc-auth.sh就可以了。

其他

如果你是在windows中新建的该文件上传到服务器执行出现BUG,那么请参考:常用工具之——dos2unix

Responses
icon_mrgreen.gificon_neutral.gificon_twisted.gificon_arrow.gificon_eek.gificon_smile.gificon_confused.gificon_cool.gificon_evil.gificon_biggrin.gificon_idea.gificon_redface.gificon_razz.gificon_rolleyes.gificon_wink.gificon_cry.gificon_surprised.gificon_lol.gificon_mad.gificon_sad.gificon_exclaim.gificon_question.gif