This guide will walk you through setting up nextcloud on unraid. I have struggled a lot when trying to setup nextcloud as I am not well versed with linux commands. I have always struggled to complete setup when a command prompt is required. After all the struggle I have managed to setup nextcloud and tweak it’s setting for the best performance possible.
Step 1 : Installation of Mariadb
In the first step you will need to install and setup Mariadb. Mariadb will be the database that will be used for the storage of all files on nextcloud. You can use the built in database that comes with Nextcloud however it is slow and therefore for better performance it is recommended that Mariadb be installed.
Once you have installed Mariadb, you will need to configure the networking of Mariadb. I have tried Bridge and host as network types, however neither of them worked. Therefore, I setup a custom IP for Mariadb. See below.
Once you have setup the network preferences on Mariadb. You are all done and you will need to move to the next step.
Step 2 : Installation of Adminer
Now that Mariadb has been setup, you need a way to create databases and users. This can be done through the command prompt, however as mentioned above, I am not well versed with Linux commands. Therefore, I use Adminer. Adminer is a graphical interface to manage your databases and their users. It is much easier to setup databases on Adminer than it is in the command prompt.
The installation of Adminer is simple and straightforward. If you need more assistance in the installation of Adminer, search youtube as there are many step by step guides available. Once Adminer has been installed, you need to configure the network so that it is on the same subnet as Mariadb. You will need to setup a customer IP address again and set the IP address within the same subnet pool. In other words in my case is is the 192.168.1.X pool. Once you have done this, it is time to move to step 3.
Step 3 : Installation of Nextcloud
The process of installing Nextcloud is simple and straightforward. Just follow the onscreen prompts to complete the setup. You will need to setup a custom network for Nextcloud as well, so that it is on the same subnet as Mariadb. This will allow our Nextcloud instance to communicate with the database we create on Mariadb. Once you have installed Nextcloud and have gone to the web UI to see it is working, it is time to create a new database on Mariadb using Adminer. Please move to step 4.
Step 4 : Creating a database on Mariadb through Adminer
Open up Adminer. You will be presented with the following screen.
You need to enter the IP address of your Mariadb instance and then you need to enter the username and password for Mariadb. The default username is root and the password is the one you set when installing Mariadb. Click on login and it will bring you to the following screen.
On this screen click create database and follow the onscreen instructions to create the database. Once the database has been created, you will need to click on the name of the database and then create a new user and password for the database. See below.
Click on Privileges to create a new user. Enter the name of the user and the password. Make sure to give full access to the user. Once done click on done. You have now created a database and a user that can access the database. Now it is time to set up Nextcloud. Got to step 5.
Step 5 : Setting up Nextcloud
When you first login to Nextcloud, you will be asked to create an account and configure your database. When configuring your database, you will need to enter the IP address of Mariadb, the name of the database, the username and the password for the database. Once you have completed these steps. Nextcloud is setup and ready for use. However there are a few tweaks that we can complete to ensure that Nextcloud runs smoothly. Go to step 6 if you would like to tweak and tune Nextcloud.
Setup 6 : Tweaking and Tuning Nextcloud
Enable PHP OPcache
PHP OPcache is one of the memory cache supported by Nextcloud. It improves the performance of PHP applications by caching precompiled bytecode. For better performance, every Nextcloud server should have this enabled.
You can enable it by adding the below lines in your 10-opcache.ini file which is located under your /etc/php directory. (For example, if you have PHP 7 installed then you will find the file in
```
=nano /etc/php82/conf.d/00_opcache.ini
```
I recommend the following settings.
```
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption= 16G
opcache.save_comments=1
opcache.revalidate_freq=1
```
Tune PHP-FPM
You may experience slow loading of the web interface in Nextcloud Server if you are using PHP-FPM. However, To overcome this issue more processes should be allowed to run even on a small installation. The below configuration is provided for an instance with 4GB of RAM and 1GB of MySQL cache. Add the below code in your www.conf file which is located:
```
nano /config/php/www2.conf
```
```
The following settings are recommended.
pm = dynamic
pm.max_children = 240
pm.start_servers = 24
pm.min_spare_servers = 12
pm.max_spare_servers = 36
Tune PHP.ini to increase upload file size
Go to the following path and search for upload_max_filesize
nano /etc/php82/php.ini
```
Change the file size to what you like.
I have tested nextcloud with postgres multiple times and with multiple versions however postgres keeps crashing. I have therefore installed Mysql as the database and I am testing it. It seems to be faster than Mariadb. Just need to make sure that the database does not crash. Once further testing has been completed I will need to add more entries to the trusted domains list and will need to setup optimisations.
This is a test to see how well I can type on this keyboard with out looking. So far I am happy with the keyboard. I am not sure how well I will enjoy this keyboard.
Add trusted Domains
```
nano /config/www/nextcloud/config/config.php
```
```
0 => '192.168.1.73',
1 => '[http://62.31.244.51](http://62.31.244.51 "http://62.31.244.51")',
2 => '[https://62.31.244.51](https://62.31.244.51 "https://62.31.244.51")',
3 => '[http://cerberuscloud.co](http://cerberuscloud.co "http://cerberuscloud.co")',
4 => '[https://cerberuscloud.co](https://cerberuscloud.co "https://cerberuscloud.co")',
5 => 'cerberuscloud.co',
6 => 'nextcloud.myserverapps.online',
7 => '62.31.244.51',
```
Redis configuration
```
Navigate to:
nano config/www/nextcloud/config/config.php
Add the following lines just before the last bracket
'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\OC\Memcache\Memcached',
'redis' =>
array (
'host' => '192.168.1.71',
'port' => 6379,
),
```
NEXTCLOUD UPDATE COMMAND
```
sudo -u abc php /config/www/nextcloud/updater/updater.phar
```
To fix large file sync issues, follow the steps below. I have not tried these steps yet but I will tomorrow.
Problem solved !
For Nginx :
Delete
```
proxy_buffering off;
fastcgi_buffers 64 4K;
```
Add this for disable buffering of responses to temporary files
```
fastcgi_max_temp_file_size 0;
```
PHP-FPM configuration :
Change request_terminate_timeout value from 45s to 3600s
```
request_terminate_timeout = 3600s
```
After that, restart php-fpm and nginx and this is how i solved my problem !
NEXTCLOUD UPDATE COMMAND
```
sudo -u abc php /config/www/nextcloud/updater/updater.phar
nano /config/nginx/site-confs/default.conf
```
512
300
Is server comes up with an error, change the client_max_body_size
cclient_body_timeout
**