Update: I recently launched a managed Nextcloud service provider with very competitive pricing for storage. If you’re planning to set up your own Nextcloud instance but have trouble finding a hosting provider with good pricing/storage ratio, please do consider signing up with us. There’s a free tier with 5GB storage so you can give the service a spin before deciding whether to upgrade the storage.
Nextcloud is the selfhosted’s community darling and probably needs no introduction. If you are a less discerning open-source tinkerer, you’d likely think that all commercial software can be replaced with Nextcloud or one of its apps.
Nextcloud can actually be installed with a click when you install a fresh copy of Ubuntu with snap but where’s the fun in that?
The following tutorial will teach you how to install Nextcloud from scratch on Debian:
- Update your package list
sudo apt update
- Install the required packages
sudo apt install nginx mariadb-server php-fpm php-mysql php-xml php-cli php-cgi php-mysql php-mbstring php-gd php-curl php-zip wget unzip ufw python3-acme python3-certbot python3-mock python3-openssl python3-pkg-resources python3-pyparsing python3-zope.interface python3-certbot-nginx -y
- Configure and run MySQL
- Create the database (change the values below accordingly)
CREATE DATABASE nextcloud;
GRANT ALL ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'nextclouduserpassword' WITH GRANT OPTION;
- Download Nextcloud (check the latest version and replace the value below accordingly)
sudo mkdir /var/www/nextcloud && sudo mv nextcloud /var/www/nextcloud/
sudo chown -R www-data:www-data /var/www/nextcloud/ && sudo chmod -R 755 /var/www/nextcloud/
- Create the Nginx configuration file for Nextcloud:
sudo nano /etc/nginx/sites-available/nextcloud
sudo ln -s /etc/nginx/sites-available/nextcloud /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
- Secure NextCloud with Let’s Encrypt Free SSL
sudo ufw allow 'Nginx Full'
sudo certbot --nginx -d cloud.example.com
- That’s it. You can now visit your configured domain to complete the Nextcloud installation and get started.
- At this point, I highly recommend one to check out occ. Note that you’ll have to run the command in the Nextcloud installation directory itself (sample commands below):
sudo -u www-data php occ -h
sudo -u www-data php occ -V
sudo -u www-data php occ app:install groupquota
- If you ever need to change the Nextcloud installation URL, just update the settings for
overwrite.cli.urlin the following file: