The Nextcloud installation page has two sets of instructions now: automatic and manual. Previously on this website, I have described the manual steps to setting up Nextcloud. It is a good learning experience and worth a try, but even better is the automatic installation using snaps.
“Snaps are containerised software packages that are simple to create and install. They auto-update and are safe to run. And because they bundle their dependencies, they work on all major Linux systems without modification.” [source]
Now, the steps are almost one step:
sudo snap install nextcloud
Reaching via different host names
By default, the only allowed hostname is “localhost”.If you are accessing your server by another name (e.g. 192.168.1.8 or nextcloud-server.com), you need to add the trusted domains.
If you access the server on your Nextcloud server machine, the website will prompt you to add the trusted domains.
Otherwise for a quicker setup, you can add your trusted domains via the command line.
sudo nextcloud.occ config:system:set trusted_domains 1 --value=192.168.1.8 sudo nextcloud.occ config:system:set trusted_domains 2 --value=nextcloud-server.com sudo nextcloud.occ config:system:set trusted_domains 3 --value=www.nextcloud-server.com
Verify the results:
array ( 0 => 'localhost', 1 => '192.168.1.8', 2 => 'nextcloud-server.com', 3 => 'www.nextcloud-server.com', ),
External Hard Drive
In order to point your Nextcloud’s data directory to an external hard drive, follow these steps, assuming your external hard drive and new Nextcloud data directory is located at:
Log into your server first and set up an admin account.
Make sure your Nextcloud server is enabled.
sudo snap enable nextcloud
Connect the remove-media snap plug so that the Nextcloud server can access your external hard drive.
sudo snap connect nextcloud:removable-media
Change the Nextcloud server’s config file to point to the new data directory, so do
And change the value of “datadirectory” to
'datadirectory' => '/media/<user>/<hard_drive_name>/nextcloud_data_directory',
Now, disable the Nextcloud server.
sudo snap disable nextcloud
And move all the data to the new data folder (including hidden files!)
sudo mv /var/snap/nextcloud/common/nextcloud/data/* /media/<user>/<hard_drive_name>/nextcloud_data_directory sudo mv /var/snap/nextcloud/common/nextcloud/data/.* /media/<user>/<hard_drive_name>/nextcloud_data_directory
Set the proper permissions so your Nextcloud server can access the hard drive and not complain:
sudo chown -R root:root /media/<user>/<hard_drive_name>/nextcloud_data_directory sudo chmod -R 0770 /media/<user>/<hard_drive_name>/nextcloud_data_directory
Re-enable your Nextcloud server
sudo snap enable nextcloud
Before using snap, verify that your domain name directs to your server. Then, use this simple snap command that will generate a Let’s Encrypt SSL certificate automatically.
sudo nextcloud.enable-https lets-encrypt
If you cannot access the files after moving to the external hard drive, you might consider reading about dropping your mysql data tables. [link]
If you want to keep your nextcloud.log file on your local disk, because it will move by default with your data directory. [link]