Nextcloud helps store your files, folders, contacts, photo galleries, calendars and more on a server of your choosing. Access that folder from your mobile device, your desktop, or a web browser. Access your data wherever you are, when you need it.

This appliance includes all the standard features in TurnKey Core, and on top of that:

  • Nextcloud Server:
    • Installed from official zip file to /var/www/nextcloud. (No automatic updates.)
    • Data directory (/var/www/nextcloud-data) outside the webroot (security).Security note: Updates to Nextcloud may require supervision so they ARE NOT configured to install automatically. See Nextcloud documentation for upgrading.
  • SSL support out of the box.
  • Adminer administration frontend for MySQL (listening on port 12322 – uses SSL).
  • Postfix MTA (bound to localhost) to allow sending of email (e.g., password recovery).
  • Webmin modules for configuring Apache2, PHP, MySQL and Postfix.

Downloading the Nextcloud Container

Expand your PVE node and navigate to the storage where you keep the container templates/ISO:

Select Templates and in the search bar top left of the new window type “Nextcloud”:

There should only be one template available, so choose turnkey-nextcloud version 16.0-1 and proceed to download.

Building the Container

Once the template has downloaded, we can go ahead and create a container:

Begin by clicking on the Create CT in the top right hand corner of your PVE:

  1. Make sure under the General tab, the Unprivileged is marked as shown
  2. Click Next
  3. Under the Template tab, select the storage where we downloaded the TKL Nextcloud template
  4. Find the debian-10-turnkey-nextcloud_16.0-1_amd64.tar.gz and select it
  5. Click Next when done
  6. Under the Root Disk tab, adjust based on your parameters
  7. Click Next
  8. Under the CPU and Memory tabs, set it based on your needs
  9. Click Next
  10. Under the Network tab, configure your network based on your environment
  11. Click Next
  12. Under the Confirm tab, do not select Start after created box
  13. Click Finish

DNS can be left empty, but I usually input the Cloudflare DNS server – 1.1.1.1 or Googles DNS – 8.8.8.8

Installation of Nextcloud

Once your container has booted, open the console – login as root and continue the installation:

  1. Enter the MySQL password for Adminer which is the frontend for MySQL
  2. Enter the password for the Nextcloud admin account
  3. Enter the domain
  4. It is up to you if you want to use the TKL services, but I skipped mine
  5. It is up to you if you want TKL notifications. I skipped mine
  6. Install the security updates
  7. The page is the appliance services. Do not go to http://<ip-address> yet to initialize Nextcloud. Click on Advanced Menu
  8. Select Quit to enter the terminal

Once we are in the terminal, navigate to /var/www/nextcloud/config/. Just in case, make a backup of the config.php.

cd /var/www/nextcloud/config/
# Make a backup of config.php
cp config.php config.php.bak

Now we need to edit the config.php file. We need to replace and add couple of lines. Adjust the value based on your use case.

  • Replace the line 0 => 'localhost' with the correct IP address 0 => 'YourIP'
  • Replace the line 'overwrite.cli.url' => 'http://localhost', with your own domain'overwrite.cli.url' => 'https://example.yourdomain.com',
  • Add the following line: 'overwritehost' => 'example.yourdomain.com',
  • Add the following line: 'overwriteprotocol' => 'https',

The config.php file should look something similar to below:

<?php
$CONFIG = array (
  'passwordsalt' => 'OPIju1935706jhaliuoiejlo*&po;',
  'secret' => '79df369621cafe8e85ba7a8cf6d794asdi23498uoidhjaoic01ae333f3cfe176198uwke42,
  'trusted_domains' => 
  array (
    0 => 'localhost',
1 => 'example.yourdomain.com',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '18.0.4.2',
  'overwrite.cli.url' => 'https://example.yourdomain.com',
  'overwritehost' => 'example.yourdomain.com',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'Ohnskie2aaasljeoia87be3ak74sy8732qydiuhf',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'instanceid' => '92fa8123425269u',
);

In addition to editing the config.php file, we need to change the owner of the nextcloud directory:

  • Change the owner of the directory /var/www/nextcloud to www-data
chown -R www-data:www-data /var/www/nextcloud

At this point, the Nextcloud LXC container should be configured. Open a web-browser and navigate to the IP address or the subdomain of the LXC container. If everything goes well, you should get the login prompt. Login to Nextcloud using the “admin” account that was created.

It is advised from here to create a new admin account and delete any other for security reasons.

About the Author

Pauraic Morrissey

Born and bred Irishman with a slight obsession with everything IT.

View All Articles