I've been a Nextcloud user off and on for the past couple of years and decided to set up a server that I can use for the long run. In my last article I detailed my reasoning, the overall infrastructure, and walked through the steps to configure the server and database. In this article I'll go through the (much shorter) process of installing and configuring Nextcloud.
Install & Configure Nextcloud
Many hosts, including Scaleway, offer the option to provision a pre-configured Nextcloud VPS instance. But since I elected to use a bare metal server I didn't have that option.
I'm going to outline the basics of my process and point out any potential problem areas. The Nextcloud installation guide is quite detailed and helpful.
The first step was to download Nextcloud and verify the file signature. Once that was done, I used SFTP to upload the zip file to the server. I then extracted the zip file in the web server root directory.
By default, Nextcloud puts its data directory inside its main directory structure. For Apache that's usually something like /var/www/nextcloud/data, which means that your file storage is exposed to the web. That's obviously a terrible idea, so I needed to make a new storage directory. Since I'm using local disks, I simply created a directory in an appropriate location. If I were using external block storage I would have put it on a separate volume to allow for easy growth and maintenance.
It's important to configure the file storage location before running the installation script. You technically can change it later, but it's a royal pain in the ass. Better to get it right from the start.
Before running the installer I needed to change the directory ownership for both the Nexcloud web and data directories.
$ chown -R www-data:www-data /var/www/path-to-nextcloud/
With everything prepared, it was time to perform the installation. I simply navigated to the web address and was presented with the installer page.

I entered all the relevant information, including my new data storage location, and hit "Install." After a couple of minutes I was at the login page.
Post-installation tasks
Once setup was complete, I signed in and navigated to the admin settings page and was greeted with a slew of warnings and messages, but most are expected and pretty easy to resolve. First up, I noticed a couple of messages about missing database indices. Those were quickly resolved by running the Nextcloud admin script from the server command line.
Most of the warning messages include directions on how to resolve them, so I worked through the list with no problems.
Configure e-mail sending
Like most server products, Nextcloud needs to occasionally send emails for things like password resets, sharing notifications, new accounts, and so on. So of course I needed to hook up an SMTP server.
In the interest of keeping everything in-house, I opted for the Scaleway Transactional Email (TEM) service. I only send a few emails per week and am not doing any marketing messages so TEM is perfect. Mailgun is another solid option with a good free tier.
I configured my mail domain via the TEM web interface and added the requisite DNS records. In an effort to prevent spam, most hosting providers disable port 25 on their servers, and Scaleway is no exception. Once I flipped the SMTP switch I was able to add my mail configuration to the Nextcloud admin interface.
I've configured Nextcloud email a few times and always have to go through a bit of trial and error with port numbers, etc. But after a few minutes I received the test message in my inbox and all was right with the world.
Configure cron
Nextcloud offers three ways to execute background tasks, but running them via cron is really the only viable way to do so, even on small installations like mine. Fortunately, this is quick and easy, so back to the command line:
$ crontab -u www-data -e
Then I added the following line to the end of the crontab:
*/5 * * * * php -f /var/www/nextcloud/cron.php
Then I returned to the Nextcloud admin page to ensure that the jobs were running as expected.

Configure the Collabora server
One of my favorite Nextcloud features is the ability to edit documents via the web interface, much like Google Docs or Microsoft 365, only without the enshittification. The installation includes a Collabora server, but I needed to set a few options via the admin interface.
I navigated to the Office tab in the admin interface and selected the built-in CODE server. This works fine for small installations, but even I find it a bit laggy at times. The next step up is to install a dedicated Collabora server. I may make that leap later on, but am fine with the bundled one for now.

Server hardening
Nextcloud has a good hardening and security guide, so I won't go into the details. I merely stepped through their guide and made sure everything was correctly set up and working.
Configure memory caching
Memory caching is important to improving server performance, and Nextcloud works with three options: APCu, memcached, and Redis. Because my server load is pretty low, I opted for APCu.
I ensured that php-apcu was installed and added the following line to my php.ini:
'memcache.local' => '\OC\Memcache\APCu'
Nextcloud still complains about transactional file locking, but that requires Redis so I'm not going to bother with it for now. I'll eventually get around to it but the server is performing fine so it's not urgent.
Complete the security scan
The last step in my installation was to run the security scan to ensure everything is uptight.
Adding modules and other setup tasks
At this point I set about installing a few additional modules, adding users, and doing some general admin and configuration tasks like setting time zones, futzing with UI elements and so on.
Conclusion
The entire setup process took me around 3-4 hours, including fixing a database that I broke (my own fault). I'm super happy with the result and will continue to refine my setup as I go.
As a good sysadmin, I keep tabs on log files and performance and make sure to run server updates weekly.
I'm sure you can tell that I'm a big fan of Nextcloud, and I think more folks should take the leap and run their own servers. As I've mentioned, there are plenty of easy ways to set it up, and you can even run it on an old computer at home without having to worry about outside network traffic. Big Tech gets worse every day, and I'm happy to have open-source alternatives that work well.
