Nextcloud Setup Guide - ajgillis04/GillisDockerDepot GitHub Wiki
Nextcloud Regular Containerized Setup Guide
Introduction
This guide provides steps to set up a Nextcloud instance using a regular containerized setup. It is ideal if you require full control over the deployment or if you’ve migrated from Nextcloud AIO.
Recommended Pre-Setup
Before setting up Nextcloud, consider deploying the following containers first to simplify integration and avoid jumping between configuration steps:
- MariaDB (For selfhosting databases)
Prerequisites
- Docker and docker-compose installed
- NAS storage or a local directory for external storage
- Environment variables for modular configuration
Configuration Steps
Step 1: Prepare the Docker Environment
-
Create / Update the
.env
file to manage configurations:NEXTCLOUD_HOMES=/path/to/homes # Avoid using symlinks; Nextcloud does not handle them well NEXTCLOUD_EXSTORAGE=/share
Create a blank database in MariaDB for nextcloud to use
docker exec -it mariadb.${HOST_NAME} /usr/bin/mariadb -u root -p CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; CREATE USER 'nextclouduser'@'%' IDENTIFIED BY 'yourpassword'; GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'%'; FLUSH PRIVILEGES; EXIT;
Run this command to test if the DB is setup correctly
docker exec -it mariadb.${HOST_NAME} mysql -u nextclouduser -p --password={your password} -e "SHOW DATABASES;"
Step 2: First-Time Setup
- Open your browser and navigate to
http://<your-server-ip>:8080
. - Select
Storage & Database
- Enter an
New admin account name
and specify the database connection:- Database account: contents of
secrets/nextcloud_mysql_user
- Database password: contents secrets/nextcloud_mysql_password
- Database Name:
nextcloud
- Database Host:
mariadb.${HOST_NAME}
- Database account: contents of
Step 3: Install Apps (Optional)
- Nextcloud asks you which apps if any you wish to install. I choose Calendar Contacts Office
Step 4: Configure Basic Settings
- Set Up External Storage:
- Enable the External Storage Support app under Settings > Apps.
Enable
, enter your password if required - Go to Settings > Administration > External storages and add your storage volumes (e.g.,
/homes
).
- Enable the External Storage Support app under Settings > Apps.
- Modify
config.php
:- Add or edit the following
Add or adjust:sudo docker run -it --rm --volume /path/to/GillisDockerDepot/appdata/nextcloud/var/www/html:/var/www/html:rw alpine sh -c "apk add --no-cache nano && nano /var/www/html/config/config.php"
'trusted_domains' => [ 'localhost', 'your-domain.com', 'your host ip example 192.168.1.100', ], 'default_phone_region' => 'CA', 'trusted_proxies' => array ( 0 => '172.30.0.0/24', # container IP range, in case IP changes 1 => '192.168.2.0/24',# domain IP range, in case IP changes 2 => '127.0.0.1', 3 => '::1', 'memcache.local' => '\\OC\\Memcache\\APCu', 'overwrite.cli.url' => 'https://nextcloud.gillisonline.com', 'overwritehost' => 'nextcloud.gillisonline.com', 'overwriteprotocol' => 'https', 'overwritewebroot' => '/', 'maintenance_window_start' => '03:00', 'memcache.locking' => '\\OC\\Memcache\\APCu',
- Save and restart the container:
docker restart nextcloud.GillisNAS
- Add or edit the following
Step 4: Optimize Performance
-
Add Missing Indices:
docker exec -it nextcloud.GillisNAS php occ db:add-missing-indices
-
Set Daily Background Jobs:
docker exec -it nextcloud.GillisNAS sudo php occ background:cron
Step 5: Maintenance and Logs
-
To clear logs:
docker exec -it nextcloud.GillisNAS bash -c "echo '' > /var/www/html/data/nextcloud.log"
-
Monitor resource usage:
docker stats
Step 6: Setting Up Auto Backups
Follow the steps from Setting Up Phone for Auto Backups in the original guide.