2

I'm trying to set ownCloud up on my Pi (following this). I've made a symbolic link from my data and config folders to a USB stick mounted at /media/cruzer_usb (as per the link), and everything works, except when I go to http://mypi/owncloud, I am told:

Can't write into config directory!

This can usually be fixed by giving the webserver write access to the config directory.

I take that to mean that www-data needs to have access to the folder, in which case, my webserver does have access to the config directory:

>sudo ls -l /var/www/html/owncloud

total 168
drwxr-xr-x 29 www-data www-data  4096 May 30 19:03 3rdparty
drwxr-xr-x 26 www-data www-data  4096 May 30 19:04 apps
-rw-r--r--  1 www-data www-data  8065 May 30 19:03 AUTHORS
lrwxrwxrwx  1 www-data www-data    24 May 30 19:16 config -> /media/cruzer_usb/config
-rw-r--r--  1 www-data www-data  3439 May 30 19:03 console.php
-rw-r--r--  1 www-data www-data 34520 May 30 19:03 COPYING-AGPL
drwxr-xr-x 16 www-data www-data  4096 May 30 19:04 core
-rw-r--r--  1 www-data www-data  5919 May 30 19:03 cron.php
lrwxrwxrwx  1 www-data www-data    22 May 30 19:15 data -> /media/cruzer_usb/data
-rw-r--r--  1 www-data www-data 32727 May 30 19:04 db_structure.xml
-rw-r--r--  1 www-data www-data   179 May 30 19:04 index.html
-rw-r--r--  1 www-data www-data  2026 May 30 19:04 index.php
drwxr-xr-x  3 www-data www-data  4096 May 30 19:03 l10n
drwxr-xr-x  5 www-data www-data  4096 May 30 19:04 lib
-rwxr-xr-x  1 www-data www-data   283 May 30 19:03 occ
drwxr-xr-x  2 www-data www-data  4096 May 30 19:03 ocs
drwxr-xr-x  2 www-data www-data  4096 May 30 19:04 ocs-provider
-rw-r--r--  1 www-data www-data  2969 May 30 19:04 public.php
-rw-r--r--  1 www-data www-data  4599 May 30 19:04 remote.php
drwxr-xr-x  5 www-data www-data  4096 May 30 19:04 resources
-rw-r--r--  1 www-data www-data    26 May 30 19:03 robots.txt
drwxr-xr-x 12 www-data www-data  4096 May 30 19:04 settings
-rw-r--r--  1 www-data www-data  1819 May 30 19:04 status.php
drwxr-xr-x  3 www-data www-data  4096 May 30 19:03 themes
drwxr-xr-x  7 www-data www-data  4096 May 30 19:04 updater
-rw-r--r--  1 www-data www-data   233 May 30 19:04 version.php

but, I keep on getting that message.

I'm out of ideas, and Googling around hasn't led me anywhere. Any help would be appreciated :)

ᔕᖺᘎᕊ
  • 223
  • 2
  • 4
  • 12

4 Answers4

3

If you want to make your USB stick fully usable by Linux programs, you should really consider formatting it as EXT2/3/4 (whichever you prefer), or at least make an EXT2/3/4 partition on it. Relying on mount permissions (set in /etc/fstab) will not work in general case: mount sets the same permissions for all files on a volume, so a program which wants its config file to have special permissions or ownership will fail. Check the tutorial you're using and note that the external drive is formatted as EXT4 there.

It's not clear what your immediate problem is. I can see the symlinks (/var/www/html/owncloud/config and /var/www/html/owncloud/data) are owned by www-data, but it's not clear what is the ownership and permissions of their targets (/media/cruzer_usb/config and /media/cruzer_usb/data). If you do sudo mount, they are likely to be owned by root. But that doesn't really matter: even if you manage to craft permissions to make Owncloud happy, you'll soon see that PHP or Apache will complain. There's no way to make Linux programs work from an NTFS volume.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
1

It looks like the link has the correct permissions, but not he directory beneath it. You should be able to solve this with

sudo chown www-data:www-data -R /media/cruzer_usb/config
Jacobm001
  • 11,904
  • 7
  • 47
  • 58
0

Try turning selinux from Enforcing to Permissive with:

sudo setenforce 0

If this works for you, then you can set it permanent by editing:

sudo vi /etc/selinux/config

and then change

SELINUX=enforcing

into

SELINUX=permissive

and reboot

0

I had the same write problem, but with a folder (apps). Yesterday I`ve did some modifications to my VM (OS Centos 7), and one of them was activation of SELinux. So in the /etc/selinux/config I have the follwing:

SELINUX=enforcing
SELINUXTYPE=targeted

The permissions to the folder where ok. Knowingly that a day before yesterday all worked ok, and the SELinux policy was disabled figured that problem was caused by SELinux. The problem was solved after changing the manage file context mapping definitions without changing any of the SELinux config policys.

semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/nextcloud(/.*)?"
restorecon -R /var/www/html/nextcloud

 $ ls -lZ | grep nextcloud
drwxr-x---. apache apache system_u:object_r:httpd_sys_rw_content_t:s0 nextcloud

You don`t need a reboot after. All back to normal now.

Mihai M
  • 9
  • 2