My installation seems to be working well, now I want to do a little bit to secure it. I have Nextcloud 10 on Ubuntu 16.04. It seems like the first thing I should do is move my data directory out of web root.
I SO don’t want to break my installation. Is there a good tutorial on how to accomplish this and verify once complete that Nextcloud is still functioning properly?
Thanks, and I have to say, I’ve been playing around with it and it’s fantastic, doing exactly what I was hoping.
If I encrypt the data directory, is this something I should even be concerned about? There will be personal data stored here that needs to be protected such as tax returns and insurance policies.
I’m not sure about encryption. I’ve only tested it with the encryption module turned off. Does the new location of the data directory still have the same permissions/ownership that your old directory had? I apologize if I lead you incorrectly. I was not aware there were database changes required.
I am a little confused here. I’ve changed the data directory multiple times without editing the database, and everything continues to work. For testing, the data directory location changes went like this,
1: Log out of Nextcloud’s web interface.
2: Move the folder to the new location.
3: Edit config/config.php and adjust the data directory path
4: Run ./occ files:scan --all
5: Log back into the web interface.
My oc_storage table looks like this,
For reference, this is Nextcloud 10. The config.php version says, ‘version’ => ‘9.1.0.16’. Would you mind clarifying the oc_storage changes? I don’t want to be giving people bad advice.
Well basically the ./occ files:scan --all fixes the storage problem. But it also breaks shares, tags, comments, … etc.
Adjusting the local::/.... id entry in storages should allow you to change the path, without breaking all the other info.
Thank you. That does clarify things. So, if you wanted to do this, the steps would be,
0: Back everything up first.
1: Disable access to Nextcloud. (maintenance mode)
2: Move the data folder.
3: Edit the database table oc_storage. Change the local::/path/to/data to local::/new/path/to/data.
4: Edit the config.php datadirectory line to reflect the new path.
5: Turn off maintenance mode.
I get the impression this is not supported, but it should work?
I’m checking the right server, am I missing something? Sorry for my lack of experience, I may just end up having to reinstall Nextcloud. Hope not, though, it’s working.
That’s odd. If Nextcloud is working, there has to be a database. Check your config/config.php file for the database type, location, and credentials. It looks something like this,
/var/www/nextcloud/config/config.php doesn’t even specify a database name. I know it’s working though because I added maintenance mode, switched it to “true”, and the site properly locked me out.
<?php
$CONFIG = array (
'instanceid' => 'zzzzzzz',
'passwordsalt' => 'zzzzzzzzzz',
'secret' => 'zzzzzzzzzzzzzzzzzz',
'trusted_domains' =>
array (
0 => 'xxx.xxx.xxx.xxx',
1 => 'share.mydomain.com',
),
'datadirectory' => '/var/www/nextcloud/data/',
'overwrite.cli.url' => 'http://xxx.xxx.xxx.xxx/nextcloud',
'dbtype' => 'sqlite3',
'version' => '9.1.0.16',
'logtimezone' => 'UTC',
'installed' => true,
'mail_smtpmode' => 'smtp',
'mail_from_address' => 'user',
'mail_domain' => 'mydomain.com',
'mail_smtpauthtype' => 'LOGIN',
'mail_smtpauth' => 1,
'mail_smtphost' => 'mail.mydomain.com',
'mail_smtpsecure' => 'tls',
'mail_smtpname' => 'user@mydomain.com',
'mail_smtppassword' => 'mypassword',
'mail_smtpport' => '25',
"maintenance" => false,
);
I also did a SHOW DATABASES and received exactly the same as what phpmyadmin was showing:
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
+--------------------+
4 rows in set (0.00 sec)
But Nextcloud is honestly working just fine. This seems crazy. ANY ideas on what might be happening?
It’s using sqlite instead of Mysql/MariaDB. I think the database will be located in your $data directory and will be a file ending with .db. I’m not entirely sure, as I’ve never configured sqlite before.
At that point my Nextcloud database was accessible through phpmyadmin. Then I followed grouchysysadmin’s steps above:
0: Back everything up first.
1: Disable access to Nextcloud. (maintenance mode)
2: Move the data folder.
3: Edit the database table oc_storage. Change the local::/path/to/data to local::/new/path/to/data.
4: Edit the config.php datadirectory line to reflect the new path.
5: Turn off maintenance mode.
In my case, I move the data directory to /etc/nextclouddata/nextcoud/data. When trying to load my login page for the first time, I got the following error:
Data directory (/etc/nextclouddata/nextcloud/data/) is invalid. Please check that the data directory contains a file “.ocdata” in its root.