bash owncloud 无法访问目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28171193/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 12:16:01  来源:igfitidea点击:

owncloud cannot access directory

bashraspberry-piowncloud

提问by kjr1995

I am running Raspbian version 7 on my raspberry pi. I am running owncloud on this. I have mounted an external drive under /media/Owncloud. This is where I have owncloud store all the files. I cannot access this directory. When I try cd /media/Owncloudit gives me the following error:
-bash: cd: /media/Owncloud/: Permission denied
How can I access this directory?

我在我的树莓派上运行 Raspbian 版本 7。我正在运行owncloud。我已经在 /media/Owncloud 下安装了一个外部驱动器。这是我拥有自己的云存储所有文件的地方。我无法访问此目录。当我尝试时,cd /media/Owncloud它给了我以下错误:
-bash: cd: /media/Owncloud/: Permission denied
如何访问此目录?

回答by q33q3

OwnCloud and external hard drives are tricky and you have a permission issue. For some reason, trying to make a link to an external hard drive has issues, so you need to try mounting your external hard drive.

OwnCloud 和外部硬盘驱动器很棘手,您有权限问题。出于某种原因,尝试链接到外部硬盘驱动器会出现问题,因此您需要尝试安装外部硬盘驱动器。

External hard drive - Apply the proper group and read permissions:

外置硬盘 - 应用正确的组和读取权限:

chown -R www-data:www-data /media/user/your_hard_drive/owncloud_data/
chmod -R 777 /media/user/your_hard_drive/owncloud_data/

Local hard drive - Apply the proper group and read permissions:

本地硬盘 - 应用正确的组和读取权限:

mkdir /var/www/owncloud/data
chown -R www-data:www-data /var/www/owncloud/data
chmod -R 777 /var/www/owncloud/data

Make the mount of local hard drive to external hard drive

将本地硬盘挂载到外置硬盘

mount --bind /media/user/your_hard_drive/owncloud_data/ /var/www/owncloud/data/

Source:

来源:

回答by Pseudonym Enigma

If you just want to cdinto the directory, change to root with sudo -i.

如果您只想cd进入目录,请使用sudo -i.

回答by Martin Malec

The issue is with wrong permissions.

问题是权限错误。

If the webserver runs as user www-data, the mounted folder must be somehow accessible to that user

如果网络服务器以用户 www-data 的身份运行,则该用户必须以某种方式访问​​安装的文件夹

  • either that user must be owner of mounted folder and its contents, and have the "user" permissions, or

  • the the folder must be accessible to the group the webserver user is in (usually www-data).

  • 该用户必须是已安装文件夹及其内容的所有者,并且具有“用户”权限,或者

  • Web 服务器用户所在的组(通常是 www-data)必须可以访问该文件夹。

To see the current permissions use the ls -lcommand.

要查看当前权限,请使用该ls -l命令。

To change the owner use chowncommand,

要更改所有者使用chown命令,

to change the permissions for the user-owner, and group-owner, use the chmodcommand,

要更改用户所有者和组所有者的权限,请使用chmod命令,

or just use Midnight commander (mc) or some GUI to do that.

或者只是使用午夜指挥官 ( mc) 或一些 GUI 来做到这一点。

If you are mounting the external volume through /etc/fstabcheck the options in there. I would not recommend using the volume with some dynamic mounting (like the file managers do (gvfs-fuse)) if is a key folder for a webserver with ownCloud and you need to have it auto-mounted on boot, as some specific user that the webserver is run as.

如果您通过/etc/fstab检查那里的选项安装外部卷。如果是带有 ownCloud 的网络服务器的关键文件夹,并且您需要在启动时自动安装它,作为某些特定用户网络服务器运行为。

I have an experience with having the ownCloud data folder on /srv/data(also ownCloud 7.0 on Ubuntu Server 14.04 VPS), the permissions are 770 and the owner is www-data:www-data, and in the ownCloud config file, I use the line

我有使用 ownCloud 数据文件夹的经验/srv/data(Ubuntu Server 14.04 VPS 上的 ownCloud 7.0),权限为 770,所有者为 www-data:www-data,在 ownCloud 配置文件中,我使用了该行

'datadirectory' => '/srv/data',

'datadirectory' => '/srv/data',

I would not recommend using 777 permissions, as it is not a good security practice in general.

我不建议使用 777 权限,因为这通常不是一个好的安全实践。

回答by Pseudonym Enigma

In order to access /media/Owncloud, you need to set the proper permissions. Run the command sudo chmod 755 /media/Owncloud(for more security relative to permission 777).

为了访问/media/Owncloud,您需要设置适当的权限。运行命令sudo chmod 755 /media/Owncloud(为了获得相对于权限 777 的更多安全性)。

You also may need to allow to webserver to access the directory. In order to do that, run sudo chown -R www-data:www-data /media/Owncloud

您可能还需要允许网络服务器访问该目录。为了做到这一点,运行sudo chown -R www-data:www-data /media/Owncloud

Sources: My own experience and frusteration in running into the exact same problem http://www.instructables.com/id/Raspberry-Pi-Owncloud-dropbox-clone/?ALLSTEPSA great albeit somewhat outdated guide to set up owncloud on a Raspberry Pi.

资料来源:我自己在遇到完全相同的问题时遇到的经验和挫折 http://www.instructables.com/id/Raspberry-Pi-Owncloud-dropbox-clone/?ALLSTEPS一个很棒的指南,虽然有些过时树莓派。