In this post I'll guide you through installing & optimising NextCloud on Intel based Terra Maters NAS's running TrueNAS 12, in this example I'm using a F2-221 with 10GB of RAM.
If your TerraMaster NAS isn't already running TrueNAS you can find my guide below that will follow you through upgrading your hardware and installing TrueNAS 12.
Start by creating a new dataset from Storage -> Pools, select the three dots on your pool then click Add Dataset.
Give your dataset a name, mine is called CloudStorage remember to set this to yours in other steps! Check the default settings match the ones below then Submit to save.
From the three dots on your newly created dataset select Edit Permissions.
Set User & Group to www, tick Apply User, Apply Group & Apply Permissions Recursively. Confirm Access Mode matches the below then click save.
From the left-hand menu select Plugins, NextCloud then INSTALL.
Name your Jail, I've called mine BifrostCloud remember to change this to yours in later steps, change NAT to DHCP to allow your router to set the new Jails IP Address. Use your router to assign the address permanently.
Copy NextCloud data directory to your new Dataset
Don't run these commands from your jail
cp -r /mnt/bifrost-pool/iocage/jails/BifrostCloud/root/usr/local/www/nextcloud/data/ /mnt/bifrost-pool/CloudStorage/
Delete NextCloud data folder
rm -r /mnt/bifrost-pool/iocage/jails/BifrostCloud/root/usr/local/www/nextcloud/data
chown -R www:www /mnt/bifrost-pool/CloudStorage/
From the Jail page stop your NextCloud instance then select MOUNT POINTS
Go to ACTIONS then Add
Now use the source/destination path as seen below except modified to fit your installation.
Add Trusted Domains
Add your assigned IP Address & Domain Name to Trusted Domains.
0 => 'localhost',
1 => '192.168.0.61',
2 => 'cloud.joelduncan.io',
Copy SSL pem & key files to the following directory
Add the following to the NextCloud Nginx configuration
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
Restart Nginx from the Jail Shell
sudo service nginx restart
sudo service nginx reload
Run these commands outside your jail
Tweak your PHP-FPM configuration
Add/Modify to match below
pm = dynamic
pm.max_children = 64
pm.start_servers = 16
pm.min_spare_servers = 16
pm.max_spare_servers = 32
Uncomment the below existing entries.
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp
Restart PHP-FPM from inside the jail
sudo service php-fpm restart
Everything is ready to go but before accessing your instance by its IP or domain you will need the MySQL and NextCloud credentials created by the plugin, you can find them in the POST INSTALL NOTES
Plugins -> NextCloud -> Drop Down -> POST INSTALL NOTES
Must be done from the Jail
php74-phar is required and can be installed with the following command
pkg install sudo php74-phar
Then the following to perform a update
sudo -u www php /usr/local/www/nextcloud/updater/updater.phar
Run OCC Commands
Must be done from the Jail
From your NextCloud installation directory
su -m www -c 'php ./occ maintenance:mode --off'