How to set/change data directory

Old FAQs for EOL ownCloud versions.
User avatar
RandolphCarter
ownCloud master
Posts: 5134
Joined: Wed May 30, 2012 8:42 am
ownCloud version: 8.1.1
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.5.x

How to set/change data directory

Postby RandolphCarter » Tue Dec 18, 2012 12:47 pm

If you don't want your data directory to reside inside your owncloud directory, there's an easy way to change it.

The easiest is to directly change it during setup: When choosing "advanced" setup method, you can set the directory in the setup wizard!


The following hints are currently unsupported!!! Reasons are currently discussed here: https://github.com/owncloud/documentation/pull/1588




But even if you have set up your owncloud already, and want to change your data directory, it can be achieved. The following guide applies for all Unix derivatives, for Windows it is not supported! (https://github.com/owncloud/core/issues ... t-76145839). You should have OC 8.0 or later (for previous versions, have a look on the bottom of this post).
  1. Stop your webserver
  2. Check if your config.php already contains a datadirectory entry. If it does, remember that location (let's assume it's '/var/www/owncloud/data' for now).
  3. Change or create the "datadirectory" entry in config.php file, so that it points to wherever you want to have your data from now on. Assuming the directory you want to move the data folder to is '/media/usbdisk/ocdata', your config.php should look like this after the change:

    Code: Select all

    <?php
    $CONFIG = array (
      'datadirectory' => '/media/usbdisk/ocdata/',
      'dbtype' => ...
  4. Make sure the "ocdata" subdirectory doesn't exist yet (or the command in the following step will move your data folder in a subdirectory of it)
  5. Move all the existing files of the original data (/var/www/owncloud/data in our example) to that new location, e.g. under linux:

    Code: Select all

    mv /var/www/owncloud/data /media/usbdisk/ocdata
  6. Make sure the permission/ownership of the new folder is set up correctly, and that all files contained in it have the user running php as owner (see e.g. here for Linux how to find out which user that is). Let's assume your apache runs as "www-data" (as it e.g. would under Ubuntu). Then you should change all folders/files to be owned by that user, like so:

    Code: Select all

    chown -R www-data:www-data /media/usbdisk/ocdata

    You can verify that the webserver can read the directory, this should show you the content of the folder:

    Code: Select all

    sudo -u www-data ls -lisa /media/usbdisk/ocdata
  7. Start your webserver
  8. Possibly (if your files don't show up) you might have to rescan your files (see e.g. here or here on how to do that)

Workarounds for Problems:

1. The PHP setting open_basedir is not allowing the access to the new datadir
2. If the datadir is placed on an external storage on linux make sure that the user running your webserver has read/write permissions to this new mountpoint. Just using the chown command doesn't help here. See "man mount" for more informations.
3. selinux is blocking the access (See this post)
4. For versions prior to 8.0, it is not officially supported (be careful! Backup!). One problem is, that there can be absolute paths in the oc_storages (to be modified after step 3).
Last edited by RealRancor on Sat Feb 13, 2016 10:53 pm, edited 9 times in total.
Reason: Added statement that this is unsupported

frank.gaurav
Newbie
Posts: 3
Joined: Wed Feb 20, 2013 2:07 pm
ownCloud version: 4.5.5

Re: How to set/change data directory

Postby frank.gaurav » Wed Feb 20, 2013 3:19 pm

I have done all the steps as you shown above. I have changed my directory to another drive but i m getting this when i access localhost ,
Please change the permissions to 0770 so that the directory cannot be listed by other users.
Evenif i change the permission of that folder to 0770
How can i resolve this ??
I also tried to change with nautilus file manager but cant change others permission might be because of the ntfs partition. Guide me..

rakekniven
Inventory
Posts: 2019
Joined: Sun May 06, 2012 3:31 pm
ownCloud version: 9.0.1
Webserver: Apache
Database: MySQL
OS: Linux Hosting Package
PHP version: 5.6.x
Contact:

Re: How to set/change data directory

Postby rakekniven » Wed Feb 20, 2013 8:43 pm

Open terminal and check your permissions

type

Code: Select all

ls -la /pathtontfs
ownCloud is not only about files. There is so much more. Explore the apps to extend your ownCloud.

User avatar
RandolphCarter
ownCloud master
Posts: 5134
Joined: Wed May 30, 2012 8:42 am
ownCloud version: 8.1.1
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.5.x

Re: How to set/change data directory

Postby RandolphCarter » Tue Mar 05, 2013 3:30 pm

See also this split off discussion: viewtopic.php?t=8728&f=3

9ler9ler
Newbie
Posts: 2
Joined: Sun Mar 10, 2013 6:04 pm
ownCloud version: 4.5.7
Webserver: Apache
Database: MySQL
OS: Linux

Re: How to set/change data directory

Postby 9ler9ler » Sun Mar 10, 2013 6:08 pm

disable selinux, reboot and follow guide.
At end of guide, enable selinux and reboot

not to pretty but it works ;)

MidwestCellRepair
Newbie
Posts: 1
Joined: Wed Mar 13, 2013 11:51 pm
ownCloud version: 4.5.7
Webserver: Apache
Database: MySQL
OS: Linux

Re: How to set/change data directory

Postby MidwestCellRepair » Thu Mar 14, 2013 5:52 pm

The cure is -

Code: Select all

chown www-data:www-data /yourdatalocation


It took me reading for hours and beating my head against the wall before it occurred to me what the login page was telling me. It wants www-data to own the entire mount/location. In my case, I created a new mount called /owncloud which is my usb drive. Once I performed the above as root# chown www-data:www-data /owncloud everything started working again.

I over-analyzed the instructions above and under-analyzed the login page. Grr.....

Regards!

gmarco
Beginner
Posts: 14
Joined: Wed Mar 20, 2013 11:50 am
ownCloud version: 5.0.0
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.5

Re: How to set/change data directory

Postby gmarco » Wed Mar 20, 2013 5:50 pm

I've been trying creating a new /home/owncloud_data/ directory.

Changed owner to apache:apache (user running apache2 on CentOS 6.3).
Changed perms to 770, 755, 777 and nothing happened. Yes I've edited my owncloud config and path is correct. I've been even trying to deal with a symbolic link but nothing seems to work.

I need to mount it in /home/ partition since it's the biggest partition i've on the system.

User avatar
RandolphCarter
ownCloud master
Posts: 5134
Joined: Wed May 30, 2012 8:42 am
ownCloud version: 8.1.1
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.5.x

Re: How to set/change data directory

Postby RandolphCarter » Wed Mar 20, 2013 10:14 pm

and nothing happened

Please elaborate what you mean by that? At which point did nothing happen? What did you expect to happen? Preferrably in a separate thread to keep the FAQ entry short and concise.

gmarco
Beginner
Posts: 14
Joined: Wed Mar 20, 2013 11:50 am
ownCloud version: 5.0.0
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.5

Re: How to set/change data directory

Postby gmarco » Thu Mar 21, 2013 9:18 am

RandolphCarter wrote:
and nothing happened

Please elaborate what you mean by that? At which point did nothing happen? What did you expect to happen? Preferrably in a separate thread to keep the FAQ entry short and concise.


With nothing happened I mean I'm still getting owncloud permission error.

I want to use /home/owncloud_data/ as my data directory. It has apache username, group and permissions set. That's why I don't understand i'm still getting this error.

If other users have managed to use a media external devices as data directory this should also work.

gmarco
Beginner
Posts: 14
Joined: Wed Mar 20, 2013 11:50 am
ownCloud version: 5.0.0
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.5

Re: How to set/change data directory

Postby gmarco » Fri Mar 22, 2013 5:44 pm

Fixed it.

It's SELINUX security being enabled by default on CentOS:

To disable it:

Code: Select all

sudo vi /etc/sysconfig/selinux

Comment the following line:
#SELINUX=enforcing

Add this line:
SELINUX=disabled


Reboot and enjoy !


  • Similar Topics
    Replies
    Views
    Last post

Return to “Historic FAQs”

Who is online

Users browsing this forum: No registered users and 0 guests