OwnCloud Change Data Directory

  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 apache:apache /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 apache 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)

Reference

Add a Comment

Your email address will not be published. Required fields are marked *

2 + 15 =