Hopefully this method should cover most details needed for a basic installation of nextcloud on a synology diskstation dsm 6. If you know something that might be helpful don’t hesitate to tell me. Btw this tutorial should work for owncloud as well.
1. Install dependencies
Start by installing the packages needed through the DSM Package center
- Web station
- Apache HTTP Server 2.4
- PHP 7.0
- MariaDB 10
2. Change default MariaDB password
- Open MariaDB 10.
- Click “Change MariaDB password”
Standard password is blank so leave the first form blank and click “reset password”
- Enter a strong password.
Virtual host or basic setup
Web Station has the ability to create virtual hosts which is handy if you want to point a specific domain to your nextcloud installation. Most people might just use their synology “quick connect” adress and place the nextcloud installation in the root of the web-folder like so: yourdsmname.synology.me/nextcloud
I have my own domain so I wanted to point it straight to my nextcloud installation. I will explain both setups in step 3.
3. (Basic setup – no virtual host).
- Open Web Station
- Go to General Settings and choose Apache 2.4 as back-end and Php 7.0 as PHP version.
3. (Alternative setup for using a virtual host).
- Open Web Station
- Go to Virtual Host and click “Create”
- Enter your hostname: yourdomain.com
- choose 80/443 for ports
- 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, and PHP 7.0 for PHP version.
Click OK and your virtual host is set up. The next steps are the same for both setups. Only thing to keep in mind is your chosen installation folder.
4. Configure PHP 7 extensions
Go to PHP Settings and select PHP 7.0 and Edit.
- First select “Customise PHP open_basedir” This is so that you can customise 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 (see image).
- Next you will need to enable certain extensions for Nextcloud to work properly
These following are enabled on my server, I honestly don’t remember which ones where specifically needed for nextcloud. You might not need all of them but it shouldn’t hurt to have them enabled:
5. Edit PHP 7 Values
Open the “Core” tab and search for the followin 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. The next steps are the actual installation steps.
6. Download the latest nextcloud
- zip from here nextcloud.com/install
- Place the nextcloud.zip in the root of your web folder (/volume1/web/) and unzip it there.
7. Fix permissions
- 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/nexctloud/ -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 in to your server through SSH
(ip-adress 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.
8. Configure Nextcloud
Now open your web browser and enter the adress of your nextcloud installation i.ex: yourdsmname.synology.me/nextcloud or yourdomain.com
If all is good you should find your self at the installation page for Nextcloud. If your page is blank or you get an error, make sure apache 2.4 and php 7 are selected in your web station/virtual host and not nginx.
9. Last step
Fill out the “form” according to your installation (see picture above)
- choose a username and password for your first user (will be an administrator)
- Enter the path to your datafolder (where you have chosen to keep your personal files)
- choose MariaDB as database (can’t find mariadb? check the notes in the bottom)
- enter the username and password that you chose earlier in step 2.
- 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
Behind a firewall?
If you are behind a firewall, make sure to port forward at least port 80 to your synology dsm to give access to your Nextcloud installation. If you are planning on using https, you need to forward port 443 as well.
HTTPS with Let’s Encrypt
A good practice is to use https 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 and security, certificate and click “add”.
For the domain name, either you can use 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',
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 value according to step 5 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 MariaBD 5.
Screen blank or error 503 or others.
I was shown several error pages during my trial and errors. Most of them where connected to Nginx, permissions or the PHP 7 -settings. Nginx is not used in this tutorial so if you get nginx errors, try changing any value where nginx is selected to apache 2.4 in web station. If it’s a permission problem, check the permissions.sh file and make sure it has the correct paths. Also make sure that “Customise PHP open_basedir” is correct according to step 4.
the PHP 7 -settings. Nginx is not used in this tutorial so if you get nginx errors, try changing any value where nginx is selected to apache 2.4 in web station. If it’s a permission problem, check the permissions.sh file and make sure it has the correct paths. Also make sure that “Customise PHP open_basedir” is correct according to step 4.
Nextcloud not working after update
If you updated your nextcloud installation you’ll need to fix your permissions again according to step 7