This is a script to setup the perfect Nextcloud Installation on a vanilla Debian 12 server.
Go to file
Ze'ev Schurmann 79956feb74 Update README.md 2025-05-07 10:03:54 +02:00
LICENSE Initial commit 2025-05-06 20:01:22 +02:00
README.md Update README.md 2025-05-07 10:03:54 +02:00
VERSION v1.03 Now tests that domainname resolves and connects to server 2025-05-07 08:58:38 +02:00
debian-installer.sh v1.03 Now tests that domainname resolves and connects to server 2025-05-07 08:58:38 +02:00

README.md

Perfect Nextcloud Installer

This is a script to setup the perfect Nextcloud Installation on a vanilla Debian 12 server. It is still a work in progress but will get your next Nextcloud installation 99% of the way to being perfect.

No fiddling with Docker or navigating your way through the terminal. Download script to server, run script, enter same basic information, wait about 20 minutes, and you can connect to your server and logon. A true bare metal install so you have 100% control of everything on the server.

Instructions to start the process is a little further down this document.

It has only been tested on Debian 12, but it should work on most Debian based distros. A vanilla server is required (nothing but Debian core and ssh installed).

I will be adding more functionality to, such as doing the last niggly settings that Nextcloud complains about as well as setup CronJobs.

I also want to add the ability for the script to detect an existing Nextcloud install and only do the system updates to bring your server inline with the latest requirements (ie new PHP version or additional modules).

And eventually I will add the ability for you to install multiple Nextclouds on the same server.

Why did I put in the time to create a script that is over 1300 lines

I am often active on the Subreddit r/NextCloud and I keep track of what most people struggle with when it comes to installing NextCloud. Also, I run a hosting company and we offer hosting for small to medium Nextcloud installations, so I install Nextcloud often. A lot of people actually contact me directly on Reddit u/thisiszeev to pay me to do the installation for them.

So I made the script so you can get an installation done the way I do it and if you feel it's worth a few dollars or so, my PayPal details are at the end of the document.

In my experience, you can get away with 2 vCPU and 4GB RAM, but I highly suggest you spend a little more and go for at least 4vCPU and 8GB RAM.

If you are going to have more than 20 active users then go for 6 vCPU and 8GB RAM.

Storage needs are for your own needs. You need about 10GB for Debian and all the extra software that needs to be installed, including a basic Nextcloud installation. The more apps you install the more space you will need for that. The rest of the storage will go to your files you keep on Nextcloud.

I would recommend starting with 50GB for a small setup of 1-3 users, and 100GB for a setup of 5-8 users. Unless you have a shit load of files you want to store, then you must go bigger, contact me on Reddit u/thisiszeev for advice.

One nice thing about a Virtual Server, Cloud Server or VPS, is that you can upgrade and downgrade vCPU and RAM quite effortlessly. Storage can easily by upgrade on 99% of providers, the other 1% there are a few steps you need to follow after the upgrade is activated. But in my experience, you can not downgrade storage.

What will be installed?

Don't panic if the script fails. You can check the file installer-errors.log to see all the latest errors that happened. Feel free to contact me on Reddit u/thisiszeev if you need advice. If I need to update the script then I will do so, test it, and make it available here.

When the cause of the error(s) is resolved, you can run the script again and it will pickup from where it left off.

Apache2

I used Apache2 over Nginx because it has a lot of flex and muscle. Sure Nginx uses less RAM and CPU resources, but unless you are running a high volume high performance installation, you will not notice it.

Apache2 will also be tested from an external source to make sure that it works on port 80 (http) and port 443 (https) as well as your domain name resolving and connecting to your server.

But be advised, our public API to that does this only allows a maximum of 10 requests per hour, and the install script needs 2, so if you have to keep running the script over and over, it will only work the first 5 times. In that event, take a break and come back in an hour, or contact me on Reddit u/thisiszeev the fist time you get an error so I can try help you fix it.

Certbot

This is used to install a free Let's Encrypt SSL certificate, because everyone loves privacy.

MariaDB

Now the default choice for a MySQL server, it's light, tight, fast and powerful. My script also hardens the MariaDB Server to help protect against potential harm. This is a step almost everyone skips, mainly because they do not know this can be done.

PHP-FPM 8.3

The latest version of Nextcloud supports up to PHP 8.3. PHP-FPM is the higher performing cousin of PHP-CGI. We will also install ALL the PHP modules that your Nextcloud will possible need.

coTURN

coTURN is a TURN/STUN server for Linux. It is a bit tricky to setup, but the script will do that all for you.

You will need coTURN if you ever want to have Video calls in Talk with people who are behind a NAT or double NAT router. Think of it as the Proxy Server for the RCP protocol.

There are some settings you will need to copy and paste into Nextcloud for it to work. The details will be published in the Installation Report file that is generated after the Install is completed.

AutoSWAP

SWAP partition cannot easily be changed down the line, but did you know you can use SWAP files instead of partitions? And the best part is you can do it all while the server is running, with zero reboots or restarts.

AutoSWAP is a Bash tool that I created to automatically manage this. When your server has more memory demand, AutoSWAP creates the needed SWAP memory, and when the demand drops away, it uncreates the unneeded SWAP memory.

Why? Simple, Nextcloud uses upto 512MB memory per active PHP session. So your memory can deplete fast resulting in failed page loads. Let AutoSWAP help avoid that.

https://git.zaks.web.za/thisiszeev/linux-server-tools/src/branch/main/swap-management

Nextcloud

Last step it downloads the latest Nextcloud, installs it completely, including a data files folder that is not inside webroot (for that extra security), activate the installation and assigns your chosen email address to the admin account. Most people struggle to get Nextcloud to connect to a mail server because they forget to add an email address to the admin account, so this installer does that for you.

Once complete, all you do is check the provided report file as indicated at the end of the installation, and there you will find all the details you need including how to log on to Nextcloud for the first time. Don't lose this file, you may need it one day.

Connect your browser to your chosen domain name, log in, enjoy. Yep, not even a Web Install to be done. All done from the script.

How to use this script?

Ideally you want to connect to your server using SSH. Log in as root, or when you log in as a user type su - and enter your root password.

For good measure type cd so that you are definately in the /root folder.

wget https://git.zaks.web.za/thisiszeev/perfect-nextcloud-installer/raw/branch/main/debian-installer.sh

Then start the script...

bash debian-installer.sh

Do you have a script idea?

If you have an idea for a useful server script for selfhost/homelab environments, please start a chat with me on Reddit /u/thisiszeev and share your idea. I might just make it a reality, and give you credit in the relevant README.md file.

Donations

Please consider making me small donation. Even though my scripts are open source and free to use, I still need to eat. And the occasional bottle of wine also goes down well.

  • $5 buys me a cup of coffee
  • $10 buys me a nice burger
  • $20 buys me a bottle of wine
  • Anything above that will be awesome as well.

You can send me a donation via Paypal https://www.paypal.com/paypalme/thisiszeev

Drop me a message on Reddit if you do make a donation. u/thisiszeev

Support is only offered freely to those who donate $20 or more.