Nextcloud does not allow moving the data folder?

Until you sets the apc.enable_cli=1 in the correct config file, please use that —define parameter for all OCC calls you do. Step 4: add the —define apc.enable_cli=1 like you did with maintenance mode.

Rawtaz, thank you for your post. Below I have posted my config.php file located on my Ubuntu Server located at the /var/www/nextcloud/config directory. I removed what I think is sensitive data and replaced it with the word “removed”. As you can see ROW 10 shows I already have datadirectory' => '/mnt/8TBdata parameter configured in my config.php file.

The problem is when I type the command line below to see what directories are inside /mnt/8TBdata I get the Permission denied message shown below:

me@mysrvr:/$ cd /mnt/8TBdata
-bash: cd: /mnt/8TBdata: Permission denied

However, the command line below allows me to see the 8TBdata folder owner is www-data. But I cannot look inside the folder even if I use sudo cd /mnt/8TBdata. I’m not experienced enough to understand why I do not have access to the /mnt/8TBdata directory not even if I use SUDO and my Ubuntu root password.

me@mysrvr:/$ cd /mnt/
me@mysrvr:/mnt$ ll
total 12
drwxr-xr-x  3 root     root     4096 Mar 19 20:53 ./
drwxr-xr-x 18 root     root     4096 Mar  5 13:46 ../
drwxr-x---  8 www-data www-data 4096 Apr  1 17:52 8TBdata/
<?php
$CONFIG = array (
  'instanceid' => 'removed',
  'passwordsalt' => 'removed',
  'secret' => 'removed',
  'trusted_domains' =>
  array (
    0 => '1xx.xxx.x.xxx',
  ),
  'datadirectory' => '/mnt/8TBdata',
  'dbtype' => 'mysql',
  'version' => '26.0.0.11',
  'overwrite.cli.url' => 'http://1xx.xxx.x.xxx',
  'dbname' => 'removed',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.removed' => true,
  'dbuser' => 'removed',
  'dbpassword' => 'removed',
  'installed' => true,
  'default_phone_region' => 'US',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'updater.secret' => 'removed',
);

Kerasit, thank you for your post. Below I have posted my config.php file located at the /var/www/nextcloud/config directory in my Ubuntu server. May you please take a look at the last row where I added the apc.enable_cli=1. Does it look correct to you? Also how many more config.php files require I make the same change to them?

Also, I noticed two PHP.ini files exist at the two locations below:
/etc/php/8.1/cli/
/etc/php/8.1/apache2/

Do these two PHP.ini files also require I add to them the code shown below?
apc.enable_cli=1

<?php
$CONFIG = array (
  'instanceid' => 'removed',
  'passwordsalt' => 'removed',
  'secret' => 'removed',
  'trusted_domains' =>
  array (
    0 => '1xx.xxx.x.xxx',
  ),
  'datadirectory' => '/mnt/8TBdata',
  'dbtype' => 'mysql',
  'version' => '26.0.0.11',
  'overwrite.cli.url' => 'http://1xx.xxx.x.xxx',
  'dbname' => 'removed',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.removed' => true,
  'dbuser' => 'removed',
  'dbpassword' => 'removed',
  'installed' => true,
  'default_phone_region' => 'US',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'updater.secret' => 'removed',
  'apc.enable_cli=1',
);

Not config.php

For now just execute all occ commands with the define parameter to php

sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/occ

That includes your step 4. From above.

When you have done that and all your occ commands has been successfull and your nc works again, we can look at adding that apc.enable_cli=1 to the correct php.ini file (not config.php).

Seems like there are two separate things being discussed here:

  • Enabling APC for the CLI seems relevant only to run occ in the CLI, but should have nothing to do with making Nextcloud access the correct/new data folder path.
  • And then there’s the making NC able to access that new data folder path issue.

If you as root (sudo should be fine as long as you verify that you are really root when you do it, e.g. by sudo id) try to cd into and ls in the new data path, what do you get? If that isn’t working, then there’s some serious problems somewhere xD

How is that /mnt/8TBdata drive mounted, what filesystem is it, etc? It seems very odd that you cannot access it as root, if that is the case.

Yes.

There are Two main things:

Folder rights to new path. And if apcu cache is defined in config.php then OCC also needs apcu to be enabled.

First thing:
Sudo Chown www-data:www-data -R /mnt/8TBdata

Second:
Ensure apc as that is needed in order to do OCC (which will tremendously enhance support and managing the system). When we can do OCC commands without hickups (by using the —define parameter we ensures that it will be enabled regardless of missing ini config).
When we can predict excactly how the system will react based on OCC - every time - we can experiment with/find the right ini file to add the apc.enable_cli=1 to the very bottom. This is needed for clean cron job anyway.

This is the two things that needs to be done.
Why it has taken so Long time to help, is that none of us thought about the config.php had changed owner to root when everything else was still owned by www-data.

So:
For now, ANY Cli command you do that has PHP in it, always have that —define apc.enable_cli=1 until we have added that one to the correct .ini file. We will look at that when your Nextcloud is up and running on new path.

Now when we are in control with and on top of apc on cli, we can execute the move of files.

You don’t need occ and APC and stuff in the CLI just to tell NC where the data resides. That’s my point. As long as APC is loaded correctly in the non-CLI part of PHP, it should be fine (or you can just disable APC entirely for now, it’s not needed for NC to function).

Yeah. But that means manually changing the config.php and that changed owner before. Safest is relying on OCC to make it cleaner, and OP has activated caching for Nextcloud. So right now the least intrusive and the things that introduces less risk of issues, is using OCC with current config and not touch config.php directly.

I see your reasoning but would not really think the same thing. But oh well, carry on :smiley:

in the mean time the config.php shows

not that it is relavant but running beta version.

Thank you to everybody for your postings. I have come to the conclusion it is best to configure your data directory location while performing Nextcloud wizard installation, as it is very difficult to move the data directory after Nextcloud wizard installation is completed. Especially, for users like me who are inexperienced. Therefore, I have decided to start from the beginning as outlined in the steps below:

Step 1: Erase 500GB NVME Boot drive and internal 8TB SSD secondary drive and reformat both drives to EXT4 format.

Step 2: Install the latest Ubuntu Server OS onto my 500GB NVME Boot drive.

Step 3: Mount 8TB SSD drive (I did not do that before. I mounted the SSD after Nextcloud was installed which was a big mistake). My new mount path wil be /mnt/8tbssd. And inside the 8tbssd directory I will make a “nxtcloud_data” directory and a “jellyfin_data” directory to store all of my personal data onto my 8tb SSD drive.

Step 4: Install Nextcloud HUB 4 Version 26. Hopefully this version has less bugs compared to what I am using right now which is Nextcloud version 25. Install PHP FPM or PHP? Install MariaDB, and install Apache 2. In short, I will refer back to the Nextcloud installation YouTube video at the link below which is what I followed for my first install:

https://www.youtube.com/watch?v=5IUKE3oA7AY

Step 5: Here is the important part. When I get to the point of the installation wizard shown in the screenshot below I will delete the “/var/www/nextcloud/data” path and instead use: “/mnt/8tbssd/nxtcloud_data”. I believe if I would have done this in my first installation I would have avoided a lot of the complications I have encountered within this particular forum thread as it relates to moving my Nextcloud data folder to a different drive.

Lastly, I hope anybody in this forum can please be so kind to post any opinion relating to what I need to do different for my second Nextcloud installation I did not cover in my Nextcloud installation steps 1 through 5 listed above. I would like to be able to install Nextcloud, Apache, PHP and MariaDB in the correct manner to avoid any complications that will prevent Nextcloud from working correctly within a local network environment (no outside WWW access needed).

Thank you for your time.

Seems completely overkill to me but I understand that if you feel this is the most controlled and simplest way for you, then that is a decision that makes sense for your situation, so go for it if it makes you sleep well! :slight_smile:

Rawtaz, thanks for the post. You are right it is overkill. But I feel I have lost control of this entire process. My hope is by starting from the beginning I will get some control back.

2 Likes

You asks php-fpm or Apache php?

Go with Apache php. That will ensure you will have simpler php ini files to keep updated. You will still need to setup apc.enable_cli=1 in your php.ini file for setting up cron, if you are going to use APCu caching, but at least it is same file as you defines memory, Max upload size and such. Makes it easier to navigate.

When you are getting more notches in your belt, you can try and use php-fpm at some point in future.