Change Nextcloud data folder location

@dnutan please how do i change the data folder for nextcloud. i have already created a folder called /home/nextcloud mounted on /dev/mapper/nextcloud with 2 terabytes space. how do i change the data folder to that location and please where is the default nextcloud folder

Nextcloud directory can be found at /usr/share/nextcloud.
Nextcloud data folder is located at /var/lib/nethserver/nextcloud.

Haven’t tried to move data location but other users did and pointed to some guides:


i tried to use the manual you shared to do it but the maintenance mode command for nextcloud does not work on nethserver

Since none of us have a working crystal ball, “does not work” is not going to get you any help. What, exactly, did you do? What, exactly, did you expect the result to be? What, exactly, was the result?

And why try to change the data directory, rather than just mounting your disk at the correct location? The latter seems the much easier way to accomplish what you’re trying to do.

crystalball rofl. Sorry for being vague. i tried to follow this tutorial so as to change the data folder and the first instruction is to put nextcloud into maintenance mode but the command listed to do that does not nork on nethserver. is there a laid down tutorial for methserver nextcloud. Please bare in mind that i changed all the paths to the appropriate nethserver paths

Again: What exact command did you run? What result did you expect? What happened instead? The only thing “does not work” tells us is that what you expected to happen, didn’t happen.

sudo -u www-data php /var/lib//nethserver/nextcloud/occ maintenance:mode --on

OK, so yes, you’ll need to adapt the commands a bit. Start here:
and here:

Though I repeat that it would probably be better for you to just mount your storage disk at the right place, so no changes to Nextcloud itself are necessary. Moving the data could result in incompatibility with future releases (of Nextcloud or of Nethserver), and also probably means it won’t be backed up.

1 Like

ok i get you. can i just mount /dev/mapper/vg_nextcloud to /var/lib/nethserver/nextcloud

Yes. Before doing that, you’d want to:

  • put Nextcloud into maintenance mode
  • Move everything from /var/lib/nethserver/nextcloud somewhere else (so the nextcloud directory is empty)

Then mount your device there, move everything back, and take Nextcloud out of maintenance mode.

OTOH, you might want to mount the disk at /var/lib/nethserver, to provide storage for all your data.

i get you loud and clear and thanks for everything. my issue is that the command given by nextcloud to put nextcloud in maintenance mode doesnt work on nethserver ```
sudo -u www-data php /var/lib//nethserver/nextcloud/occ maintenance:mode --on

The two links I gave above will tell you how to correct that problem.

i believe it should be

sudo -u apache /opt/remi/php73/root/usr/bin/php /usr/share/nextcloud/occ maintenance:mode --on

please be sure t change the php to the version you are using to maybe php72 from php73

/opt/remi/changehere/root/usr/bin/php that part need to absolute path to your php file

or you could edit the .htaccess file and turn it on and issue

sudo -u apache /opt/remi/php73/root/usr/bin/php /usr/share/nextcloud/occ maintenance:update:htaccess

again making sure your php file path is correct

ok @Kirk_macdonald so i shoulld run php -v to know the version and then change it accordingly. secondly can i try to reload nethserver and i create this path from the onset /var/lib/nethserver on the hard drive i want to use so that nextcloud will use it as default

no as nethserver use php 5.4 by default my suggestion is

yum install -y

yum install -y

yum -y install nethserver-php-scl --enablerepo=stephdl

then issue

sudo -u apache /opt/remi/php73/root/usr/bin/php /usr/share/nextcloud/occ maintenance:mode --on

or manually via the .htaccess file then issue

sudo -u apache /opt/remi/php73/root/usr/bin/php /usr/share/nextcloud/occ maintenance:update:htaccess

I will have a look at your other question after i get back frm school run gotta dash im running late after writing this lol

IIRC, Nethserver’s Nextcloud uses php7.1, instead of the default upstream version (5.4). So usually there’s no need to install php7 manually.

this is correct but when you issue the occ command it complains and tells you occ does not work with php5.4

How can I run Nextcloud’s occ command?
occ command should be run as the HTTP user (apache) and with the same php version used by your Nextcloud instance. Here are two possible ways to call occ command:

su - apache -s /bin/bash -c “source /opt/rh/rh-php71/enable; cd /usr/share/nextcloud/; php occ”

sudo -u apache /opt/rh/rh-php71/root/usr/bin/php /usr/share/nextcloud/occ

1 Like

Guys!!! I cracked it!!! I didnt use any of the commands. all i did was Format the server and during installation setup, I created the /var/lib/nethserver Directory on sdb with 2Terabytes space. Nextcloud will automatically create the folder there. Thanks Guys you are duly appreciated

1 Like