What is Nextcloud? Nextcloud is the most deployed self-hosted file share and collaboration platform on the web. Access and collaborate across your devices. The Nextcloud application is functionally similar to Dropbox or OneDrive. Unlike Dropbox and OneDrive, Nextcloud does not offer off-premises file storage hosting. Nextcloud is free and open-source, which means that anyone is allowed to install and operate it on their own private server devices.
Follow the instructions below to install Nextcloud on your Synology Nas device. You can install it on your DSM version 6.2.2 +.
1. Install all Package dependencies. Start by installing this bunch of packages through the DSM Package Center (Step 1)
- Web Station
- Apache HTTP Server 2.4
- PHP 7.3
- phpMyAdmin 4.9.1
- MariaDB 10
2. Change the default MariaDB password (Step 2)
Follow the instructions in the below and in the image.
- Open MariaDB 10.
- Click “Change MariaDB password”.
- Standard password is blank. Leave the first form blank and click “Reset root password”.
- Enter a strong password.
Virtual host or Basic setup? Synology Package “Web Station” has the ability to create virtual hosts if you want to point a specific domain to your Nextcloud installation. Most people might just use their Synology “Quick Connect” address and place the Nextcloud installation in the root of the web-folder like so: yourdsmname.synology.me/Nextcloud
In my case I have my own domain so I wanted to point it straight to my Nextcloud installation.
3. Basic setup – No Virtual Host (Step 3)
Follow the instructions below and in the image.
- Open Web Station Package.
- Go to General Settings.
- Choose Apache 2.4 as HTTP back-end server.
- Choose PHP 7.3 as PHP. (old screenshot show PHP 7.2)
(Alternative setup for using a virtual host).
Follow the instructions in the images below.
- Open Web Station Package
- Go to Virtual Host and click “Create”
- Enter your hostname: yourdomain.com
- Choose Ports 80/443
- For Document root: click browse and select the folder where you want to install Nextcloud. If you choose /web/nextcloud you will be able to access your Nextcloud installation both through your virtual hostname and through yourdsmname.synology.me/nextcloud
- Choose Apache 2.4 for HTTP back-end server
- Choose PHP 7.3 for PHP (old screenshot show PHP 7.2)
Click OK and your Virtual Host is set up. The next steps are the same for both setups (virtual host or no virtual host). Only thing to keep in mind is your chosen installation folder.
4. Router Port Forwarding (Step 4)
Search Port Forwarding on your own Router Settings; every router has its own graphic interface. Remember to open the following ports on the “Port Forwarding” router settings (see below). After having done so, save the settings. Port 80 will allow visitors to visit your site, port 443 will allow visitors to visit the site via SSL protocol.
Follow the instructions in the image below.
Port 80 on TCP
Port 80 on UDP
Port 443 on TCP
Port 443 on UDP
5. Configure PHP 7 extensions (Step 5)
Follow the instruction in the images below.
- Open Web Station Package.
- Go to PHP Settings and select PHP 7.3 and Edit. (old screenshot show php 7.2)
First select “Customize PHP open_basedir” This is so that you can customize where to put your Nextcloud data-folder (where you will keep all your personal files). It’s a good idea to keep your data folder away from your Nextcloud installation. At the end of the open_basedir: type a semi colon and enter the path to your data folder.
Next you will need to enable certain extensions on PHP settings for Nextcloud to work properly:
- Required PHP module Extensions for Nextcloud:
- PHP module ctype
- PHP module curl
- PHP module dom
- PHP module GD
- PHP module iconv
- PHP module JSON
- PHP module libxml (Linux package libxml2 must be >=2.7.0)
- PHP module mbstring
- PHP module openssl
- PHP module posix
- PHP module session
- PHP module SimpleXML
- PHP module XMLReader
- PHP module XMLWriter
- PHP module zip
- PHP module gd
- PHP module mysqli
- PHP module pdo_mysql
- PHP module bz2
6. Edit PHP 7 Values (Step 6)
Open the “Core” tab and search for the following values and change them accordingly:
mysql.default_port=3307 (this is the default port for MariaDB 10)
Now you have prepared an environment where Nextcloud should work perfectly. The next steps are the actual installation steps.
7. Download the latest Nextcloud Files (Step 7)
Download the latest zip file from here: nextcloud.com/install
Place the nextcloud.zip in the root of your web folder (/volume1/web/) and unzip it there.
8. Fix permissions (Step 8)
Open a text editor and paste the following text.
#!/bin/bash< chown -R http:http /volume1/web/nextcloud/ chown -R http:http /volume1/web/nextcloud/apps/ chown -R http:http /volume1/web/nextcloud/config/ chown -R http:http /volume1/web/nextcloud/themes/ chown -R http:http /PATH/TO/DATAFOLDER/ chown http:http /volume1/web/nextcloud/.htaccess find /volume1/web/nextcloud/ -type f -print0 | xargs -0 chmod 777 find /volume1/web/nextcloud/ -type d -print0 | xargs -0 chmod 777 find /PATH/TO/DATAFOLDER/ -type d -print0 | xargs -0 chmod 777 chmod 777 /volume1/web/nextcloud/.htaccess
Edit the paths to match your environment.
Save your script as permissions.sh and upload it to your Synology Nas.
Run your permissions file
Log into your server through SSH
(ip-address works fine too)
(if ssh is disabled you need to enable it first through the Control Panel and in “Terminal & SNMP” select “Enable SSH service”
go to the directory where you saved you permissions.sh file
Run the file:
when prompted, type your admin password and press enter.
9. Configure Nextcloud (Step 9)
Now open your web browser and enter the address of your Nextcloud installation i.e.: yourdsmname.synology.me/nextcloud or yourdomain.com
If all is good, you should find yourself at the installation page for Nextcloud. If your page is blank or you get an error, make sure Apache 2.4 and PHP 7.32 are selected in your web station/virtual host and not nginx.
Possible Errors: MariaDB not showing up on Nextcloud install screen
If you can’t find MariaDB once you’ve arrived at the Nextcloud installation screen, make sure that MariaDB is installed and that you have changed the PHP 7.3 value according to step 6 to 3307. If for some reason it refuses to save 3307 and defaults to 3306 (which is MariaDB 5), try to install MariaDB 5 as well. This might make it visible for Nextcloud. You should still be able to choose 127.0.0.1:3307 for host, to force it to use MariaDB 10. If not, you might consider trying to install the MariaDB 5 Package on your Synology Nas.
10. Last step (Step 10)
Fill out the “form” according to your installation (see picture above).
- Choose a username and password for your first user (which will be an administrator).
- Enter the path to your datafolder (where you have chosen to keep your personal files).
- Choose MariaDB 10 as database (If you can’t find it, as previously mentioned, install the MariaDB 5 Package).
- Enter the username and password that you chose earlier, in (Step 2) of this article.
- Choose any name for the database, just no spaces or leave it for default.
- Enter 127.0.0.1:3307 as hostname to make sure Nextcloud connects properly to MariaDB.
Steps to consider after installation:
HTTPS with Let’s Encrypt
A good practice is to use https (SSL) on any web site unless the access to your website is only on a local network. Synology has built in Let’s Encrypt which support great and free SSL certificates.
Create Let’s Encrypt certificate
Go to Control Panel / Security, Certificate and click “add”.
For the domain name, you can use either your Synology Quick Access name or you can use your own domain, just make sure your domain is pointing to your diskstation.
Unless you are using subdomains, just leave the “Subject Alternative Name:” blank.
Force HTTPS through .htaccess
Go to your Nextcloud installation folder and edit config.php in the config folder. Find the overwrite.cli.url value and change the http to https:
‘overwrite.cli.url’ => ‘https://yourdomain.com’