Install Nextcloud on Synology NAS Diskstation DSM 6

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
  • Phpmyadmin
  • 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:
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.
Web Station Apache and PHP setup

3. (Alternative setup for using a virtual host).

  • Open Web Station
  • Go to Virtual Host and click “Create”
  • Enter your hostname:
  • 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
  • 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:

  • bz2
  • curl
  • gd
  • mysqli
  • openssl
  • pdo_mysql
  • zip

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)
  • opcache.enable=1
  • opcache.enable_cli=1
  • opcache.interned_strings_buffer=8
  • opcache.max_accelerated_files=10000
  • opcache.memory_consumption=128
  • opcache.save_comments=1
  • opcache.revalidate_freq=1

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
  • Place the 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.

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 and upload it to your synology nas.

    Run your permissions file
  • Log in to your server through SSH
    ssh [email protected]
    (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 file
    cd /path/to/directory/
  • Run the file:
    sudo ./

    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: or

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 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' => '',

Problem Solving

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 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 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 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


  1. I want to change the default ports 80, 443 to 880 and 4443 since I am already port forwarding 80 internally for a media server and 443 for a VPN server.

    The question is what are the config files that I would have to do this with? Apache? PHP?

    Any guides or references on this would be appreciated.

    • Hi GB, sorry for my late reply. I would set it up using virtual hosts as explained in step 3. If you need to use a different port (which you most likely wont if you just set it up to use virtual host) instead of clicking the default port 80, choose your own ports right below for both http and https. That should do the trick.

    • Thanks Evie. That’s probably the most random and nicest comment yet, it certainly makes me want to write a part 2, what should it be about? =)

  2. I get pleasure from, result in I found just what I was taking
    a look for. You have ended my 4 day lengthy hunt! God Bless you man. Have
    a great day. Bye

  3. Hi David
    great guideline for the nextcloud installation. I am facing two problems:
    1.) I have already in the Webstation my webpage configured. When I want to add a new virtual host for nextcloud it does not allow me to use the host name
    2.) Using PHP 7 I can’t set the extensions under PHP settings. Possibility to do so is not displayed. FYI: I am using DSM 6.1.7

    • Hey Michael, sorry for the late reply.
      1. Nextcloud doesn’t really “care” which hostnames you use. You set the www root directory for the new hostname in webstation. After that make sure that the nextcloud folder is in that directory. That should be enough.
      2. This I have no clue about I’m afraid. Can you ta a screenshot and link to it so I can see what the settings look like?

  4. Greetings! Quick question that’s totally off topic.

    Do you know how to make your site mobile friendly?
    My weblog looks weird when viewing from my iphone. I’m trying to
    find a theme or plugin that might be able to correct this issue.
    If you have any recommendations, please share. Cheers!

    • Hi Brenna. Not sure I’m going to be a good help for you. There are a few different ways to do this. There are plugins that let your site detect if your visitors are using a mobile device and can “redirect” them to a special theme made for a mobile devices. That’s how most people used to do it. Today the most common way is just to look for a responsive theme that you like, which means that the page will resize itself depending on the size of the screen. But they can look “weird” if you have lots of content that doesn’t work with smaller screens. You can also choose to not display certain elements depending on the screen size by setting css rules. I don’t know if that helps. Cheers!

  5. Hi,
    Thanks you very much for your tutorial. With your help, I succeeded to install Nextcloud 13 on my NAS Synology 713+.
    After I custumized my config/config.php file, Nextcloud displayed an error message : impossible to use it. But after I used again the script, the problem disappeared.


  6. Hi,

    Thanks for this great guideline ! I’m kind of new on this, but I’m nearly at the end of it, but…

    when I run the file I got theses errors :

    [email protected]:~$ sudo /volume1/COMMUN/
    /volume1/COMMUN/ line 1: {rtf1ansiansicpg1252cocoartf1504cocoasubrtf830: command not found
    /volume1/COMMUN/ line 2: syntax error near unexpected token `}’
    /volume1/COMMUN/ line 2: `{\fonttbl\f0\fmodern\fcharset0 Courier;}’

    I 100% sure that I missed something since I’m a total beginer.. Does theses errors can help you to point me my mistake ?

    Thanks in advance for your help !



  7. Hi,
    Really like the blog.
    However, I don’t seem to get it working.
    When using my internal ip:
    I get the screen and everything seems to work (although I didn’t test to much).

    when I use
    I always get redirected to something like
    which doesn’t exist.

    If i use on my lan (where the nas is)
    I get redirected to

    Any idea what I should check?

  8. Hi, It looks like you might have gotten a few random characters and line breaks in the file. Maybe copying the text from the browser didn’t work correctly. Send me a pm through the contact page or chat bubble and I can send you the file as a zip. It should work.

  9. I think the problem might be related to quickconnect. I rarely use it since it rarely works for anything except connecting to the DSM. I would try using DDNS in the control panel > external access > DDNS and add a domain. Then try connecting to and see if that works.
    Regarding your lan there could be multiple reasons for this. Have you set up a virtualhost? if so you could add that virtual host to your /etc/hosts file on your computer if it’s linux/osx or you might be able to add it to your router depending on model. That way, you override any DNS queries and point it straight to your NAS. If you use Virtual host and want external access you would need to register that domain some where and you might need to enable nat loopback on your router if it doesn’t work. I don’t know if any of that helps, don’t hesitate to ask again or if I was unclear.

  10. Thank you so much for this. I now have a fully working Nextcloud installation on my Synology DS218+. I now want to make sure everything is backed up. I use Hyperbackup to backup the whole web folder, and another to backup the app MariaDB. Am I doing enough to ensure my calendar and contacts are backed up? I’ve been searching so much online, but all I have found are instructions to backup a Linux based Nextcloud installation. I can’t adapt the instructions for a Synology install.

    Any advice would be gratefully received!

    Thank you.

    • I’m glad you found it helpful! Yes the web folder (and volume folder if placed somewhere else) and database is enough for backing up your installation. Just make sure to backup any encryption keys you have separately as well if you decide to use encryption on nextcloud, those won’t get backed up in the database. Other wise you should be good!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.