Nextcloud Setup Guide - ajgillis04/GillisDockerDepot GitHub Wiki
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.
Before setting up Nextcloud, consider deploying the following containers first to simplify integration and avoid jumping between configuration steps:
- MariaDB (For selfhosting databases)
- Docker and docker-compose installed
- NAS storage or a local directory for external storage
- Environment variables for modular configuration
-
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;"
- 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
- Nextcloud asks you which apps if any you wish to install. I choose
- Calendar
- Contacts
- Nextcloud Office
- Notes
-
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.$<HOST_NAME>
- Add or edit the following
-
Set up a whitelist for your IP. Top right, select the A, administrative settings, security, brute-force IP whitelist, Add a new whitelist. Add your ISP assigned IP. I use
/24
in case my ISP changes my IP.
Note: This helps prevent locking yourself out in case of misconfiguration. -
Set password policy as per your requirements.
-
Set up the email server. From the administration, go to basic settings, email server, and enter the settings.
Note: This ensures users receive messages when their accounts are created. -
Set up users and groups. Click on the A at the top right, then accounts.
Note: I use a script to create my accounts, e.g.,
export OC_PASS=whateverpassword /var/www/html/occ user:add --password-from-env --display-name="Test User" --group="users" [email protected]
-
Setup external storage, Click on the A top right, apps, your apps, scroll to bottom and enable External storage
- Go to
External storages
under theAdministration
section and set your external storage.
I create a Documents folder for each user on the NAS that points back to their home drive and a few others
Note: For NASShares I also turn on enable sharing allowing me to create shares for others. - Go to
-
Last step I do is add my domain, local IP, and phone code to the config.php
sudo docker run -it --rm --volume nextcloud:/var/www/html:rw alpine sh -c "apk add --no-cache nano && nano /var/www/html/config/config.php"
- Open the Nextcloud app and enter the Server address
*Note: You will be redirected to your browser to enter your Nextcloud credentials.
- Connect to your account.
-
Grant Access
-
Navigate to Documents.
-
Tap + and select Create new Folder.
-
Name the new folder Photos.
-
Go back twice.
-
Open the Burger menu.
-
Go to Settings.
-
Select Auto upload.
-
Tap … (ellipsis) and configure the folder you want to upload.
-
Enable Auto upload.
-
Change the Remote folder to the newly created Photos folder.
-
To clear logs:
docker exec -it nextcloud.GillisNAS bash -c "echo '' > /var/www/html/data/nextcloud.log"
-
Monitor resource usage:
docker stats
Follow the steps from Setting Up Phone for Auto Backups in the original guide.