The complete guide to installing Nextcloud on Debian 10

Today we’re installing the free and open source cloud platform Nextcloud on a machine running Debian 10. Nextcloud is, in a nutshell, a secure self-hosted replacement for Dropbox, Google Docs and Google Calendar. You should own your data – not the big companies. The guide somewhat resembles the WordPress how-to – as we did then we set up a database, a web server and a website written in PHP that is meant to sit behind a reverse proxy giving it a secure connection to the internet.

Just a note: there are more simple ways of doing this, either by using Docker (link here) or by using Snaps (link here) – but you won’t get the same ability to tweak, configure or add third party apps. And most importantly, you won’t learn how it works.

I. The Database

We start off with installing a relational database management system.

apt -y install mariadb-server mariadb-client

Then we set it up, use a long secure password for the root user.


Now it’s time to create the database and database user Nextcloud will be using.

mysql -u root -p
CREATE USER 'nextcloud_user'@'localhost' IDENTIFIED BY 'super-secure-password'; CREATE DATABASE nextcloud_db; GRANT ALL PRIVILEGES ON nextcloud_db.* TO 'nextcloud_user'@'localhost'; FLUSH PRIVILEGES; QUIT

II. The Web Server

Since Nextcloud is written in PHP, we have to install it (and some extensions).

apt -y install php php-{cli,xml,zip,curl,gd,cgi,mysql,mbstring,imagick,intl}

The last thing we have to install is our web server that will be hosting our Nextcloud instance.

apt -y install apache2 libapache2-mod-php

With that done we have to make a few adjustments to the PHP settings, search for and replace the following values in /etc/php/7.3/apache2/php.ini.

nano /etc/php/7.3/apache2/php.ini
date.timezone = Europe/Stockholm memory_limit = 512M upload_max_filesize = 500M post_max_size = 500M max_execution_time = 300

It’s time to download the latest version of Nextcloud (at the time of writing it is 18).

wget unzip

Then we place it in our website folder (by default /var/www/html) and change the permissions, but first we delete the default website Apache installed.

rm /var/www/html/index.html cd nextcloud/ mv * /var/www/html/ mv .htaccess /var/www/html/ mv .user.ini /var/www/html/ chown -R www-data:www-data /var/www/html chmod -R 755 /var/www/html

Since it’s more secure not storing your data in a subfolder to /var/www we create a dedicated folder for Nextcloud data outside of it.

mkdir /nextcloud-data chown -R www-data:www-data /nextcloud-data

Now we edit our Apache configuration so that it looks something like this – use your own email and website address.

nano /etc/apache2/sites-available/nextcloud.conf
<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName ServerAdmin DocumentRoot /var/www/html ServerName <Directory /var/www/html/> Options +FollowSymlinks AllowOverride All Require all granted <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/html SetEnv HTTP_HOME /var/www/html </Directory> # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost>

Then we activate our configuration and enable some needed Apache modules with the following commands.

unlink /etc/apache2/sites-enabled/000-default.conf ln -s /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/ a2enmod rewrite a2enmod headers a2enmod env a2enmod dir a2enmod mime systemctl restart apache2

If your IP address for the server is and your website address is, you have to do the following edits to the Nextcloud config in order to be able to access the website.

nano /var/www/html/config/config.php
'trusted_domains' => array ( 0 => '', 1 => '', 2 => '', ),

The website is now accessible! Head over to it by writing the servers IP address in your browser ( in our example case). Use the database account we created (nextcloud_user), the database (nextcloud_db) and our data folder (/nextcloud-data).

We could now say that we’re finished, but we are not! There still is some tweaks to be made…

III. Additional Fixes

If you head to http://your-ip-address/settings/admin/overview you can see if there are some errors. One I got was:

The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running “occ db:add-missing-indices” those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster.

This was fixed with the following commands.

cd /var/www/html/ apt install sudo sudo -u www-data php occ db:add-missing-indices

Another error I got was:

Some columns in the database are missing a conversion to big int. Due to the fact that changing column types on big tables could take some time they were not changed automatically. By running ‘occ db:convert-filecache-bigint’ those pending changes could be applied manually. This operation needs to be made while the instance is offline. For further details read the documentation page about this.

This was fixed with:

sudo -u www-data php occ db:convert-filecache-bigint

Then in order to get “pretty URL:s” we edit the Nextcloud config.

nano /var/www/html/config/config.php
'overwrite.cli.url' => '', 'overwritehost' => '', 'htaccess.RewriteBase' => '/',

Then we update Nextcloud with our new settings.

cd /var/www/html/ sudo -u www-data php occ maintenance:update:htaccess

We’re almost done, but first we have to change how Nextcloud handles background tasks from using ajax to cron. We do this by adding a cronjob and then changing it in the website settings (http://your-ip-address/settings/admin).

crontab -u www-data -e
*/5 * * * * php -f /var/www/html/cron.php

The final step in our journey is to set up caching, it will greatly improve the performance of your cloud. The caching solution we will be using is APCu, let’s install it!

apt install php-apcu systemctl restart apache2

After installing APCu we have to enable it, by writing the following in /var/www/html/config/config.php.

nano /var/www/html/config/config.php
'memcache.local' => '\OC\Memcache\APCu',

Then we enable it in the PHP settings by adding a line to /etc/php/7.3/apache2/php.ini.

nano /etc/php/7.3/apache2/php.ini

And that is it! You are now the owner of your very own cloud. 🙂

P.S. if you find something wrong with the guide please tell me so I can fix it!

13,078 thoughts on “The complete guide to installing Nextcloud on Debian 10”

  1. Looks great

    I have nextcloud already for myself
    But I have a question. What is the reason for switch from ajax to Cron?


    1. The downside being AJAX requires regular visits to the page to trigger the background job, a Cron job works all the time.

  2. When i strictly follow this guide on debian 10 inside a proxmox lxc i cant get past the first login screen.
    I get an internal server error and the trusted domains array is showing on top of the page accesing it via local ip adress Oo

      1. Trevor Watson

        same here

        ‘trusted_domains’ => array ( 0 => ‘’, 1 => ‘nextcloud.local’, 2 => ‘www.nextcloud.local’, ),
        shows at the top of the page , and in the middle

        Internal Server Error
        The server was unable to complete your request.

        If this happens again, please send the technical details below to the server administrator.

        More details can be found in the server log.

        Technical details
        Remote Address:
        Request ID: Zvl4MAg7US9bntLYBsoH

        1. Trevor Watson

          OK got it sorted after reading the comment from Airless . I had to delete /var/www/html/config/config.php (rm /var/www/html/config/config.php), then navigate to the nextcloud instance, log in and “finish the configuration” and then edit /var/www/html/config/config.php

          So the correct order of steps is –
          1) After restarting apache navigate to the nextcloud instance
          2) create the admin account and finish the configuration
          3) edit /var/www/html/config/config.php with the trusted domains

          Thanks for guide though 👍👍👍👍👍

          1. Trevor Watson

            Actually editing the /var/www/html/config/config.php creates problems when logging in subsequently (at least in version 20anyway). So you don’t need to do step 3 in my reply above. After restarting apache just navigate to the nextcloud instance, create the admin account and password, specify the data folder and database user, password and database to use, and “finish the configuration”

  3. Aw, this was a really good post. Finding the time and actual effort
    to produce a top notch article… but what can I say… I hesitate a lot and never manage
    to get anything done.

  4. Thanks for putting this together. I followed your steps and ran in an few issue caused by the last steps.
    – Adding your trusted domains to the config.php needs to be done after you first navigate to the installation page and enter your DB info, etc… In Nextcloud there is no config.php until you complete the web installation steps.

    I’m betting SLEVIN did what I did and made a copy of the config.php.sample, made the edits you suggested and received server errors because the sample config uses different dependencies than your setup.

  5. Hi, I do think this is a great web site. I stumbledupon it 😉 I will revisit yet again since i have bookmarked it.
    Money and freedom is the greatest way to change, may you be rich
    and continue to guide others.

  6. Thanks for your personal marvelous posting! I definitely enjoyed reading it, you will be a great author.I will be sure to bookmark your blog and definitely will come back down the road. I want to encourage you continue your great writing, have a nice weekend!|

  7. Hey just wanted to give you a quick heads up. The text in your post seem to be running off the screen in Internet explorer. I’m not sure if this is a formatting issue or something to do with browser compatibility but I figured I’d post to let you know. The design look great though! Hope you get the issue fixed soon. Thanks|

  8. With havin so much written content do you ever run into any issues of plagorism or copyright violation? My website has a lot of exclusive content I’ve either written myself or outsourced but it appears a lot of it is popping it up all over the web without my agreement. Do you know any techniques to help prevent content from being stolen? I’d really appreciate it.|

  9. It is truly a great and helpful piece of info. I am happy that you shared this useful info with us. Please keep us informed like this. Thanks for sharing.|

  10. Hi there would you mind letting me know which webhost you’re utilizing? I’ve loaded your blog in 3 different internet browsers and I must say this blog loads a lot quicker then most. Can you suggest a good internet hosting provider at a fair price? Thanks a lot, I appreciate it!|

  11. Awesome blog! Do you have any suggestions for aspiring writers? I’m hoping to start my own website soon but I’m a little lost on everything. Would you propose starting with a free platform like WordPress or go for a paid option? There are so many options out there that I’m totally overwhelmed .. Any tips? Thanks!|

  12. Greetings from California! I’m bored to death at work so I
    decided to browse your site on my iphone during lunch break.

    I enjoy the knowledge you present here and can’t wait
    to take a look when I get home. I’m amazed at how quick your blog loaded on my cell phone ..
    I’m not even using WIFI, just 3G .. Anyhow, very good site!

  13. I do not even understand how I stopped up here, however I believed this put up used to be good. I do not realize who you are but definitely you are going to a well-known blogger for those who are not already. Cheers!|

  14. I really like your blog.. very nice colors & theme. Did you design this website yourself or did you hire someone to do it for you? Plz reply as I’m looking to create my own blog and would like to find out where u got this from. thanks a lot|

  15. First off I want to say wonderful blog! I had a quick question which I’d like to ask if you don’t mind. I was interested to find out how you center yourself and clear your thoughts before writing. I have had trouble clearing my thoughts in getting my ideas out there. I truly do enjoy writing however it just seems like the first 10 to 15 minutes are lost just trying to figure out how to begin. Any ideas or hints? Cheers!|

  16. you are really a excellent webmaster. The website loading velocity is amazing. It kind of feels that you are doing any distinctive trick. In addition, The contents are masterpiece. you have performed a magnificent job on this subject!|

  17. Greetings from Colorado! I’m bored to tears at work so I decided to check out your blog on my iphone during lunch break. I love the information you provide here and can’t wait to take a look when I get home. I’m amazed at how quick your blog loaded on my phone .. I’m not even using WIFI, just 3G .. Anyhow, wonderful blog!|

  18. Heya just wanted to give you a quick heads up and let you know a few of the pictures aren’t loading correctly. I’m not sure why but I think its a linking issue. I’ve tried it in two different browsers and both show the same outcome.|

  19. Wonderful blog! I found it while browsing on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Many thanks|

  20. Really Great work Man, Thanks for your long list, this saved me a lot of time to find those Blog Commenting submission sites. At the same time I’ve been making some of them in the hope to get high quality backlinks to my site. All of the posts on your blog are having informative and valuable content. Appreciate your efforts.

  21. Great post! Blog commenting is an acquired skill which depends on a couple of factors which are very well explained and articulated especially favourable circumstances to comment on blogs. Thanks and cheers!

  22. However, its not a matter of commenting on blogs, whats most important is the type of comments you’re leaving on those blogs, if they’re engaging and interesting enough then, they will likely come with so many benefits.Really Nice List Impressive collection of some great blog sites.Blog commenting is really one of the easiest way to build up a following around your blog. I am sure that every bloggers should have known this fact by now. Some Links are not work properly but overall a nice lists.

  23. Thank you so much for the article. I have been looking for such an article on how to perform SEO in 2019. Also, kindly help me with the topic that Google is counting directories as spam these days.

  24. You actually make it seem really easy together with your presentation however I to find this topic to be really something that I believe I might by no means understand. It sort of feels too complex and very large for me. I’m taking a look forward to your next publish, I’ll try to get the cling of it!|

  25. You really make it appear so easy along with your presentation but I in finding this matter to be actually something which I feel I’d by no means understand. It seems too complex and very large for me. I’m taking a look forward on your next put up, I’ll attempt to get the cling of it!|

  26. Hello are using WordPress for your site platform? I’m new to the blog world but I’m trying to get started and create my own. Do you require any html coding knowledge to make your own blog? Any help would be really appreciated!|

  27. Heya i am for the first time here. I found this board and I find It truly useful & it helped me out a lot. I hope to give something back and aid others like you aided me.|

  28. Excellent blog! Do you have any recommendations for aspiring writers? I’m hoping to start my own blog soon but I’m a little lost on everything. Would you recommend starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m totally overwhelmed .. Any suggestions? Thanks a lot!|

  29. Hey there! I simply want to offer you a huge thumbs up for the excellent information you have got here on this post. I will be returning to your web site for more soon.|

  30. What’s up every one, here every person is sharing these familiarity, thus it’s pleasant to read this blog, and I used to pay a visit this blog all the time.|

  31. I am really loving the theme/design of your web site.
    Do you ever run into any browser compatibility issues?
    A few of my blog readers have complained about my blog not operating correctly in Explorer but looks great
    in Chrome. Do you have any recommendations to help fix this issue?

  32. Hmm is anyone else encountering problems with the pictures on this blog loading? I’m trying to figure out if its a problem on my end or if it’s the blog. Any responses would be greatly appreciated.|

  33. Spot on with this write-up, I honestly believe this amazing site needs a lot more attention. I’ll probably be back again to read more, thanks for the information!|

  34. Hey there! I know this is kinda off topic nevertheless I’d figured I’d ask. Would you be interested in exchanging links or maybe guest authoring a blog post or vice-versa? My website addresses a lot of the same subjects as yours and I feel we could greatly benefit from each other. If you happen to be interested feel free to send me an e-mail. I look forward to hearing from you! Terrific blog by the way!|

  35. Just want to say your article is as amazing. The clarity in your post is simply nice and i could assume you are an expert on this subject. Fine with your permission let me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please continue the gratifying work.|

  36. I do not even know how I ended up here, but I thought this post was good. I don’t know who you are but definitely you are going to a famous blogger if you are not already 😉 Cheers!|

  37. It is perfect time to make some plans for the future and it’s time to be happy. I have learn this post and if I may I desire to suggest you few interesting things or advice. Perhaps you can write subsequent articles relating to this article. I wish to read more issues approximately it!|

  38. Great post. I was checking continuously this blog and I’m impressed! Very useful information particularly the last part 🙂 I care for such information much. I was seeking this certain info for a long time. Thank you and best of luck.|

  39. I want to to thank you for this very good read!! I definitely loved every little bit of it. I have got you book-marked to check out new stuff you post…|

  40. Does your website have a contact page? I’m having a tough time locating it but, I’d like to send you an email. I’ve got some recommendations for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it expand over time.|

  41. You really make it seem so easy with your presentation but I find this topic to be really something that I think I would never understand. It seems too complicated and extremely broad for me. I am looking forward for your next post, I will try to get the hang of it!|

  42. Hi there to all, how is the whole thing, I think every one is getting more from this website, and your views are fastidious in support of new users.|

  43. It’s actually a cool and useful piece of info. I’m happy that you just shared this helpful info with us. Please keep us up to date like this. Thank you for sharing.|

  44. Oh my goodness! Impressive article dude! Thanks, However I am encountering difficulties with your RSS. I don’t know why I am unable to join it. Is there anybody getting the same RSS problems? Anybody who knows the solution can you kindly respond? Thanx!!|

  45. What’s up, the whole thing is going perfectly here and ofcourse every one is sharing information, that’s actually fine, keep up writing.|

  46. Nice post. I was checking continuously this weblog and I am impressed!
    Very useful info specially the ultimate section 🙂 I take care of such info much.

    I was seeking this certain information for a long time.
    Thanks and good luck.

  47. This is really fascinating, You are an overly skilled blogger.
    I have joined your rss feed and look forward to in quest of extra of your fantastic post.
    Also, I have shared your web site in my social networks!

  48. Appreciating the persistence you put into your website and detailed information you
    offer. It’s awesome to come across a blog every once in a while that isn’t the same old rehashed information. Wonderful read!

    I’ve saved your site and I’m adding your RSS feeds to my Google account.

  49. Wow, marvelous blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your web site is fantastic, as well as the content!|

  50. My family every time say that I am wasting my time here at net, except I know I am getting experience every day by reading such nice articles or reviews.|

  51. Wonderful beat ! I would like to apprentice whilst you amend your web site, how could i subscribe for a blog site? The account helped me a appropriate deal. I had been tiny bit familiar of this your broadcast offered bright transparent concept|

  52. Hello there, simply became alert to your weblog through Google, and found that it’s truly informative. I am going to be careful for brussels. I’ll appreciate in case you continue this in future. Many people will probably be benefited from your writing. Cheers!|

  53. Have you ever thought about writing an ebook or guest
    authoring on other sites? I have a blog based on the
    same ideas you discuss and would really like to have you share some stories/information. I know my viewers would appreciate your work.
    If you’re even remotely interested, feel free to shoot me an e mail.

    Also visit my homepage – project manag;,

  54. Fantastic site you have here but I was wondering if you knew of any user discussion forums that cover the same topics discussed in this article? I’d really love to be a part of community where I can get feedback from other experienced individuals that share the same interest. If you have any recommendations, please let me know. Bless you!|

  55. I rarely leave comments, but i did a few searching and wound up here The complete guide to installing Nextcloud on Debian 10 – Albin A.
    Henriksson. And I actually do have a couple of questions for you if it’s allright.

    Is it just me or does it appear like some of the comments come across as if they are
    written by brain dead visitors? 😛 And, if you are posting at other sites,
    I’d like to keep up with everything new you have to post.
    Would you make a list of all of your public pages like your linkedin profile, Facebook page or twitter feed?

    My homepage – latest hcl placement preparations (Kristofer)

  56. Sweet blog! I found it while browsing on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Thanks|

  57. Fantastic post but I was wondering if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit more. Appreciate it!|

  58. I’ve been surfing online more than three hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. Personally, if all webmasters and bloggers made good content as you did, the internet will be a lot more useful than ever before.|

  59. I believe what you said made a great deal of sense.
    But, think on this, suppose you wrote a catchier post title?
    I ain’t suggesting your content isn’t solid, however suppose you added a headline that makes people want more?
    I mean The complete guide to installing Nextcloud on Debian 10 – Albin A.
    Henriksson is a little vanilla. You might peek at Yahoo’s home page and note how they create news headlines to get people to
    open the links. You might try adding a video or a related picture or two to grab people interested
    about everything’ve got to say. Just my opinion, it
    would bring your website a little bit more interesting.

    Here is my web blog: software,,

  60. Way cool! Some very valid points! I appreciate you penning this post and
    the rest of the website is also really good.

    Feel free to visit my blog software (

  61. As I web-site possessor I believe the content matter here is
    rattling magnificent , appreciate it for your hard work.
    You should keep it up forever! Best of luck.

    Here is my web page; software (

  62. As I site possessor I believe the content material here
    is rattling wonderful , appreciate it for your hard work.

    You should keep it up forever! Good Luck.

    Feel free to surf to my blog post – software (

  63. Hey very cool website!! Guy .. Excellent .. Superb ..
    I’ll bookmark your blog and take the feeds additionally? I am
    happy to seek out a lot of useful information right here within the post, we
    need work out more techniques in this regard, thank you for sharing.

    . . . . .

    Review my web blog: answers (

  64. Keep up the superb piece of work, I read few posts on this site and I believe that your web blog is really interesting
    and holds sets of wonderful information.

    Have a look at my site – answers (

  65. I get pleasure from, cause I found just what I used to be taking a look for. You have ended my 4 day lengthy hunt! God Bless you man. Have a nice day. Bye|