_**User Exp**_ | <markstyle="background:yellow;color:black">average</mark> | Easy-to-use service but syncing can be buggy
_**Pricing**_ | <markstyle="background:yellow;color:black">average</mark> | Within market rate
 
---
 
### Structure and usage
 
NextCloud is a Cloud Management solution with integrated Apps that aims at managing and syncing a vast array of data between connected devices. This section gives an overview of the structure of the service.
 
#### Host
NextCloud needs to be hosted on a server with two options available:
Apache2 has notorious issues with over-clogging memory usage (topping 100% of memory usage).
In order to minimise memory usage, [[#APCu]] has been installed as a cache manager. In addition, Appache has been paired with:
- **[php-fpm](https://www.php.net/manual/en/install.fpm.php)** for php7.4, enabling faster interaction between apache and backend.
- the '**event**' multi-processing module ([MPM](https://tecadmin.net/apache-mpm-prefork-and-worker-and-event/)) enabling decluttering of processing between ports & Apache
All relevant dependencies have been installed and the set-up tested.
A comprehensive tutorial on the MPM switch can be found [here](https://www.digitalocean.com/community/tutorials/how-to-configure-apache-http-with-mpm-event-and-php-fpm-on-ubuntu-18-04) or [here](https://askubuntu.com/questions/1319861/how-to-configure-apache-http-to-php-fpm-on-ubuntu-20-10).
**php.ini** files can be found at:
```ad-path
/etc/php/7.4/fpm/php.ini
/etc/php/7.4/apache2/php.ini
/etc/php/7.4/cli/php.ini
```
 
##### Certbot
[[#^Top|TOP]]
Provides SSL certification from **Let's Encrypt**. Installation dependencies are different from Nginx and explained [here](https://linuxhint.com/secure-apache-lets-encrypt-ubuntu/)
 
##### MySQL
Nothing particular to note on MySQL apart from initial set-up and user management.
Configuration file is under:
```ad-path
/etc/mysql/mysql.conf.d/mysqld.cnf
```
```ad-code
title: Optimise memory usage of mysql
~~~yaml
[mysqld]
% Disable performance schema to hugely reduce RAM usage
performance_schema = OFF
~~~
```
In order to restart mysql, the command is:
```ad-command
~~~bash
sudo service mysql restart
~~~
```
 
##### APCu
[[#^Top|TOP]]
Memory caching addon for Nextcloud. Memory caching management is provided by Nextcloud and needs to be set up as a system cron job. After installing APCu, the webserver needs to be **restarted** and the cron job defined:
Nextcloud offers two alternatives for managing the service:
1. An admin webpanel
2. A command line tool
 
##### Admin webpanel
Accessed through login into the service with admin credentials. Settings offer an admin section.
 
##### Nextcloud command line tool
[[#^Top|TOP]]
From the server's command line, Nextcloud offers the ability to perform some tasks like user management.
 
###### Introduction to the command
[[Nextcloud]] offers a command-line tool which permission needs to be set to "executable". It is located here:
```ad-path
/var/www/html/nextcloud/occ
```
The tool needs to be invoked by the "www-data" user and compiled with PHP:
```ad-command
~~~bash
sudo -u www-data php /var/www/html/nextcloud/occ
~~~
```
 
###### Generic commands
[[Nextcloud]] offers a simple description of all commands [here](https://docs.nextcloud.com/server/22/admin_manual/configuration_server/occ_command.html)