Any old minimal hardware configuration will work just fine for technology testing, but I wouldn’t want to rely on a single LXC container running off an old PC to serve tens of thousands of users and terabytes of data. Planning an enterprise-scale deployment? Nextcloud provides a useful, multi-level Deployment Recommendations guide to provisioning full-strength platforms.

Here, for instance, is what Nextcloud recommends for a smaller work group with up to 150 users accessing up to 10TB of data:

One sever with 2 CPU cores

16GB of RAM

Authentication through Lightweight Directory Access Protocol (LDAP) (a widely-used distributed information protocol)

Red Hat Enterprise Linux or Ubuntu 16.04 _with_ vendor support

Apache with TLS/SSL encryption certificate

Apache with TLS/SSL encryption certificate The MySQL or MariaDB database

The Btrfs file system mounted with _nodatacow_ for Nextcloud data partitions to permit _zero downtime_ backups

Caching with memcache to speed up access performance

Building a LAMP server

Building a base environment suitable for testing the package should be simple enough. Here are all the packages you’ll need for your server in a single command. I threw in wget and nano just in case they’re not already installed. In the interest of keeping the base image as small as possible, packages like nano are often not installed by default on some virtualized platforms like LXC containers.

# apt install apache2 mariadb-server libapache2-mod-php7.0 \

php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring \

php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip \

wget nano

If you’re not picky about using MySQL rather than MariaDB — and you’re on an Ubuntu server — then you could just as easily spare yourself a lot of typing and go with the LAMP server metapackage I mentioned in the previous chapter. Again: don’t forget the caret (`^`) at the end of the package name.

# apt install lamp-server^

Once installed, don’t forget to run the MySQL secure installation tool:

# mysql_secure_installation

If you chose the MariaDB route and found yourself having to use sudo with that command, here’s a quick fix:

MariaDB [(none)]> SET PASSWORD = PASSWORD(‘your-password’);

MariaDB [(none)]> update mysql.user set plugin = ‘mysql_native_password’ where User=’root’;

MariaDB [(none)]> FLUSH PRIVILEGES;

Apache configuration

To ensure that Apache will be able to communicate with Nextcloud, there are a few relatively simple adjustments you’re going to have to make. First off, you should enable a couple of Apache modules through the a2enmod tool. The rewrite module is used to rewrite URLs in real time as they’re moved between a client and the server. The headers module performs a similar function for HTTP headers.

# a2enmod rewrite

# a2enmod headers

If you’re not planning to use this server for any other purpose, locating the Nextcloud application files in the Apache document root would work. Since the value of the `DocumentRoot` entry in the 000-default.conf file in your /etc/apache2/sites-available/ directory already points to /var/www/html/, there’s really nothing left for you to do.

However, placing Nextcloud’s data files in the default document root presents a potential security risk, so you will probably want your Nextcloud application in some other part of your file system.

There are two ways to tell Apache how to find site files that aren’t in the document root. The “Ubuntu method” involves adding a new section to your existing 000-default.conf file that contains all the necessary information. However, most people seem to prefer creating a new .conf file in the /etc/apache2/sites-available/ directory for each new service. Both work just fine, but here’s what the separate file should look like assuming you placed the application in /var/www/ rather than the document root:

Alias /nextcloud “/var/www/nextcloud/” <Directory /var/www/nextcloud/>

Options +FollowSymlinks

AllowOverride All <IfModule mod_dav.c>

Dav off

</IfModule> SetEnv HOME /var/www/nextcloud

SetEnv HTTP_HOME /var/www/nextcloud </Directory>

Note that the “Alias” line associates the contents of the /var/www/nextcloud/ directory with the “nextcloud” host (or “site”), and the two “SenEnv” lines assign environment variables that will define the way the Nextcloud application works

A similar directive using the Ubuntu method would involve adding a section in your 000-default.conf file that might look something like this:

<VirtualHost *:443> <1>

ServerName bootstrap-it.com

DocumentRoot /var/www/nextcloud

ServerAlias bootstrap-it.com/nextcloud <2>

</VirtualHost>

As you can see in the figure, when Apache reads this file, it will redirect all incoming traffic addressed to example.com/nextcloud to the application files in /var/www/ (assuming, again, that your domain is example.com…as before, an IP address will work just as well).