Install Nextcloud into root-directory of my Domain


I want to use the guide from @JasonBayton ( to install Nextcloud with ACPu, Apache2 and nice URLs :wink: Is there any way to have Nextcloud in instead of

I hope you can help me :slight_smile:

I quickly read the link you provided, you should edit the configuration you made in apache2

$ sudo vim /etc/apache2/sites-available/nextcloud.conf


 DocumentRoot /var/www/html


 DocumentRoot /var/www/html/nextcloud/

and restart the service:

$ sudo service apache2 restart

And the Rewrite-Base-settings:
(should be similar in Nextcloud)

1 Like

Yes, exactly, thanks @tflidd

‘htaccess.RewriteBase’ => ‘/’,

and use the occ maintenance:update:htaccess as said in the link to regenerate the .htaccess

What they said :slight_smile: I run my production install in the root -

But rather than editing nextcloud.conf to change the DocumentRoot I moved the contents of /nextcloud into /var/www/html/ directly. that way when I bring down a new version, I unpack that into /nextcloud and move the relevant files and directories over to the root.

It’s up to you how you do it.

After activating the pretty URLs it is not longer possible to view videos :cry:
…is MySQL installed secure (no access from external) with apt install lamp-server?

The redirecting from HTTP to HTTPS is also not working for me - also if I follow the tutorial 100% :grin:

I hope you can help me out :slight_smile:

I’ll do another test install later today against my guide to confirm it’s working. Not seeing videos is likely a bug?

Out of interest, is your default 000-default.conf site still enabled?

ls /etc/apache2/sites-enabled to see if it’s there.

The optional redirect I have there relies on the 000-default site being disabled with sudo a2dissite 000-default.conf and an apache reload/restart. I don’t know why, but I didn’t include that in the guide (edited now). I can confirm that prior to disabling that, it wouldn’t redirect, but as soon as I did + apache restart, it worked fine.

An interesting one for me; I followed my own tutorial and everything was going fine up until pretty URLs, which enabled but failed to work (displaying directory listing instead) - on inspection, everything above “Do not edit above this line” in .htaccess was missing.

Adding that in resolved.

Any idea why the htaccess didn’t generate correctly @LukasReschke @tflidd @nickvergessen?

Just a few remarks to your guide:

  • check if there is a default-ssl.conf in sites-enabled, you might have to disable this as well

  • Inside your nextcloud.conf, you should add this

    <Directory /var/www/html/>
    Options +FollowSymlinks
    AllowOverride All

    Dav off

    SetEnv HOME /var/www/html
    SetEnv HTTP_HOME /var/www/html


That’s a bug. I will check on OC 9.1 and report on github…

Thanks @tflidd. I can add point one but default-ssl.conf is always disabled on Ubuntu until manually enabled.

For point two thanks, will add that in. Up to this point my installations haven’t included the extras in the conf file or any SSL hardening and have been fine, but it’d be wrong not to promote best practices :thumbsup:

1 Like

The only reason I see for this is:

$htaccessContent = file_get_contents($setupHelper->pathToHtaccess());
$content = "#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####\n";
$htaccessContent = explode($content, $htaccessContent, 2)[0];

So if the code was missing before, it will also miss afterwards. But other then that it updates correctly here.

Well it didn’t because I made a backup copy before. So where is the difference? my config/config.php:

    "system": {
        "instanceid": "ocx7851qw981",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
        "datadirectory": "\/var\/www\/nextcloud\/data",
        "overwrite.cli.url": "https:\/\/\/nextcloud",
        "htaccess.RewriteBase": "\/nextcloud",
        "dbtype": "mysql",
        "version": "",
        "dbname": "nextcloud",
        "dbhost": "localhost",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "logtimezone": "UTC",
        "installed": true,
        "user_backends": [
                "class": "OC_User_IMAP",
                "arguments": [
        "": "beta",
        "loglevel": 2,
        "maintenance": false,
        "updater.server.url": "https:\/\/\/updater_server\/",
        "updater.secret": "***REMOVED SENSITIVE VALUE***"

I was checking again, now it work. I also found the error:
Instead of copying the old .htaccess file, I accidentally moved it (so there was no original one).

Is this resolved? Did you backup the .htaccess before?

Absolutely fresh install. Didn’t touch anything before/after enabling pretty URLs and running the occ command.

I resolved by copying in everything above “do not edit” from my production environment and saving.

Thank you :slight_smile: Your new guide works for the Force-SSL things. I have now pretty URLs etc. under my root-directory. Data is stored in /var/cloud-data :wink: The only problem is, that videos are not playable :grin: My log:

Error	index	Exception: {"Exception":"RedisException","Message":"Redis server went away","Code":0,"Trace":"#0 \/var\/www\/html\/nextcloud\/lib\/private\/Memcache\/Redis.php(114): Redis->incrBy('8a73d596d967558...', 1)\n#1 \/var\/www\/html\/nextcloud\/lib\/private\/Lock\/MemcacheLockingProvider.php(73): OC\\Memcache\\Redis->inc('files\/d5c46342e...')\n#2 \/var\/www\/html\/nextcloud\/lib\/private\/Files\/Storage\/Common.php(651): OC\\Lock\\MemcacheLockingProvider->acquireLock('files\/d5c46342e...', 1)\n#3 \/var\/www\/html\/nextcloud\/lib\/private\/Files\/Storage\/Wrapper\/Wrapper.php(584): OC\\Files\\Storage\\Common->acquireLock('files\/Documents...', 1, Object(OC\\Lock\\MemcacheLockingProvider))\n#4 \/var\/www\/html\/nextcloud\/lib\/private\/Files\/Storage\/Wrapper\/Wrapper.php(584): OC\\Files\\Storage\\Wrapper\\Wrapper->acquireLock('files\/Documents...', 1, Object(OC\\Lock\\MemcacheLockingProvider))\n#5 \/var\/www\/html\/nextcloud\/lib\/private\/Files\/View.php(1910): OC\\Files\\Storage\\Wrapper\\Wrapper->acquireLock('files\/Documents...', 1, Object(OC\\Lock\\MemcacheLockingProvider))\n#6 \/var\/www\/html\/nextcloud\/lib\/private\/Files\/View.php(2013): OC\\Files\\View->lockPath('\/Documents\/Abou...', 1, false)\n#7 \/var\/www\/html\/nextcloud\/lib\/private\/Files\/View.php(1106): OC\\Files\\View->lockFile('\/Documents\/Abou...', 1)\n#8 \/var\/www\/html\/nextcloud\/lib\/private\/Files\/View.php(963): OC\\Files\\View->basicOperation('fopen', '\/Documents\/Abou...', Array, 'r')\n#9 \/var\/www\/html\/nextcloud\/lib\/private\/Preview\/TXT.php(48): OC\\Files\\View->fopen('\/Documents\/Abou...', 'r')\n#10 \/var\/www\/html\/nextcloud\/lib\/private\/Preview.php(1142): OC\\Preview\\TXT->getThumbnail('\/Documents\/Abou...', 2048, 2048, false, Object(OC\\Files\\View))\n#11 \/var\/www\/html\/nextcloud\/lib\/private\/Preview.php(777): OC\\Preview->generatePreview(5)\n#12 \/var\/www\/html\/nextcloud\/lib\/private\/Preview.php(802): OC\\Preview->getPreview()\n#13 \/var\/www\/html\/nextcloud\/core\/ajax\/preview.php(64): OC\\Preview->showPreview()\n#14 \/var\/www\/html\/nextcloud\/lib\/private\/Route\/Route.php(155) : runtime-created function(1): require_once('\/var\/www\/html\/n...')\n#15 [internal function]: __lambda_func()\n#16 \/var\/www\/html\/nextcloud\/lib\/private\/Route\/Router.php(293): call_user_func('\\x00lambda_20', Array)\n#17 \/var\/www\/html\/nextcloud\/lib\/base.php(967): OC\\Route\\Router->match('\/core\/preview.p...')\n#18 \/var\/www\/html\/nextcloud\/index.php(48): OC::handleRequest()\n#19 {main}","File":"\/var\/www\/html\/nextcloud\/lib\/private\/Memcache\/Redis.php","Line":114}	2016-08-31T12:01:44+00:00	admin
Error	PHP	Cannot modify header information - headers already sent by (output started at /var/www/html/nextcloud/3rdparty/sabre/http/lib/Sapi.php:83) at /var/www/html/nextcloud/3rdparty/sabre/http/lib/Sapi.php#63	2016-08-31T11:56:16+00:00	admin
Error	PHP	Cannot modify header information - headers already sent by (output started at /var/www/html/nextcloud/3rdparty/sabre/http/lib/Sapi.php:83) at /var/www/html/nextcloud/3rdparty/sabre/http/lib/Sapi.php#58	2016-08-31T11:56:16+00:00	admin

Lol, Redis server went away. Hopefully it comes back soon?

Is Redis up and running OK? Check your system logs for clues as Redis is a system package.

I am running this instance on a 512 MB RAM Server with 1 Core. Is it possible, that there is not enough resources left for redis?!

In order to know, we’d really need to see what it’s doing.

As you’re on 16.04, what does the output of sudo systemctl status redis give you? Mine looks like:

● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2016-08-29 18:15:42 BST; 2 days ago
  Process: 297 ExecStartPost=/bin/run-parts --verbose /etc/redis/ (code=exited,     status=0/SUCCESS)
  Process: 294 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
  Process: 287 ExecStartPre=/bin/run-parts --verbose /etc/redis/redis-server.pre-up.d (code=exited,     status=0/SUCCESS)
 Main PID: 296 (redis-server)
    Tasks: 3
   Memory: 6.2M
      CPU: 8min 16.858s
   CGroup: /system.slice/redis-server.service
          └─296 /usr/bin/redis-server

Furthermore, what do you see in sudo less /var/log/redis/redis-server.log and sudo less /var/log/syslog ?