"apps root directory not found!" RuntimeException

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 18.0.2): 18.0.5
Operating system and version (eg, Ubuntu 20.04): Raspbian Linux 10
Apache or nginx version (eg, Apache 2.4.25): nginx (1.14.2-2+deb10u1)
PHP version (eg, 7.1): 7.3

The issue you are facing:
I am getting frequently “apps root directory not found!” RuntimeException. Everything was working fine until I installed wordpress and used nginx host proxy. Now I run nextcloud from sub-directory along side wordpress. Wordpress site is running perfectly, but nextcloud not. Nextclouid starts working again if I restart php7.3-fpm service for say 10 minutes and then starts failing again until next php-fpm restart. nginx configuration and nextcloud config.php is as explained in nextcloud installation docu. I also tried adding “apps_paths” from config.php, but no luck!

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Install nextcloud /var/www/nextcloud and use nginx with nextclod as root
  2. Install wordpress and change nginx to use wordpress and nextcloud from sub-directories with host proxy.

The output of your Nextcloud log in Admin > Logging:

192:{"reqId":"UCyUq5AI2PHSEwMYWg4S","level":3,"time":"2020-06-01T14:42:02+00:00","remoteAddr":"91.89.13.213","user":"--","app":"core","method":"GET","url":"/settings/admin/overview","message":{"Exception":"OC\\HintException","Message":"Memcache \\OC\\Memcache\\Memcached not available for distributed cache","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Server.php","line":626,"function":"__construct","class":"OC\\Memcache\\Factory","type":"->","args":["1e84de47f5a5a221302cc2f4b8f669c5",{"__class__":"OC\\Log"},"\\OC\\Memcache\\APCu","\\OC\\Memcache\\Memcached",null]},{"file":"/var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":125,"function":"offsetGet","class":"Pimple\\Container","type":"->","args":["OC\\Memcache\\Factory"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":162,"function":"query","class":"OC\\ServerContainer","type":"->","args":["OC\\Memcache\\Factory"]},{"file":"/var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":114,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":125,"function":"offsetGet","class":"Pimple\\Container","type":"->","args":["MemCacheFactory"]},{"file":"/var/www/nextcloud/lib/private/Server.php","line":1647,"function":"query","class":"OC\\ServerContainer","type":"->","args":["MemCacheFactory"]},{"file":"/var/www/nextcloud/lib/private/Server.php","line":589,"function":"getMemCacheFactory","class":"OC\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":125,"function":"offsetGet","class":"Pimple\\Container","type":"->","args":["OCP\\IURLGenerator"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":162,"function":"query","class":"OC\\ServerContainer","type":"->","args":["OCP\\IURLGenerator"]},{"file":"/var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":114,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":125,"function":"offsetGet","class":"Pimple\\Container","type":"->","args":["URLGenerator"]},{"file":"/var/www/nextcloud/lib/private/Server.php","line":1620,"function":"query","class":"OC\\ServerContainer","type":"->","args":["URLGenerator"]},{"file":"/var/www/nextcloud/lib/private/Server.php","line":1100,"function":"getURLGenerator","class":"OC\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":125,"function":"offsetGet","class":"Pimple\\Container","type":"->","args":["OC\\Template\\JSCombiner"]},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":344,"function":"query","class":"OC\\ServerContainer","type":"->","args":["OC\\Template\\JSCombiner"]},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":174,"function":"findJavascriptFiles","class":"OC\\TemplateLayout","type":"::","args":[["core/js/dist/main","js/merged-template-prepend","search/js/search","core/l10n/en","search/l10n/en","search/js/searchprovider","js/files/fileinfo","js/files/client"]]},{"file":"/var/www/nextcloud/lib/private/legacy/template.php","line":184,"function":"__construct","class":"OC\\TemplateLayout","type":"->","args":["error",""]},{"file":"/var/www/nextcloud/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/legacy/template.php","line":333,"function":"printPage","class":"OC\\Template\\Base","type":"->","args":[]},{"file":"/var/www/nextcloud/index.php","line":57,"function":"printExceptionErrorPage","class":"OC_Template","type":"::","args":[{"__class__":"OC\\HintException"},500]}],"File":"/var/www/nextcloud/lib/private/Memcache/Factory.php","Line":113,"Hint":"Is the matching PHP module installed and enabled?","CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0","version":"18.0.4.2"}
193:{"reqId":"cgxx4Y5TBwCFdQ7DhlB0","level":2,"time":"2020-06-05T14:15:18+00:00","remoteAddr":"","user":"--","app":"appstoreFetcher","method":"","url":"--","message":"Could not connect to appstore: cURL error 28: Operation timed out after 10000 milliseconds with 1409024 out of 5028022 bytes received (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)","userAgent":"--","version":"18.0.4.2"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'replaced',
  'passwordsalt' => 'replaced',
  'secret' => 'replaced',
  'trusted_domains' =>
  array (
    0 => 'replaced.com',
    1 => 'cloud.replaced.com',
    2 => 'www.replaced.com',
  ),
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/nextcloud/apps',
      'url' => '/nextcloud/apps',
      'writable' => true,
    ),
  ),
  'datadirectory' => '/media/HDD1/nextcloud',
  'dbtype' => 'pgsql',
  'version' => '18.0.5.1',
  'overwrite.cli.url' => 'https://replaced.com',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'replaced',
  'dbpassword' => 'replaced',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'replaced',
  'mail_domain' => 'replaced.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.replaced.com',
  'mail_smtpport' => '587',
  'mail_smtpname' => 'replaced@replaced.com',
  'mail_smtppassword' => 'replaced',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'updater.secret' => 'replaced',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'updatechecker' => true,
  'overwriteprotocol' => 'http',
);

The output of your Apache/nginx/system log in /var/log/____:

upstream php-handler {
 #server 127.0.0.1:9000;
 server unix:/var/run/php/php7.3-fpm.sock;
}

server {
 listen 80;
 listen [::]:80;
 server_name replaced.com www.replaced.com 192.168.178.replaced;

 root /var/www/wordpress;


 location ^~ /.well-known/acme-challenge {
    proxy_pass http://127.0.0.1:81;
    proxy_redirect off;
 }

 
 location / {
          # Enforce HTTPS
	  #return 301 https://$server_addr$request_uri;
 
          # Use this if you always want to redirect to the DynDNS address (no local access).
	  return 301 https://$server_name$request_uri;
        }
}

server {
	listen 127.0.0.1:81;
	server_name 127.0.0.1;	
	
	location ^~ /.well-known/acme-challenge {
		default_type text/plain;
		root /var/www/letsencrypt;
	}
}

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name replaced.com www.replaced.com 192.168.178.replaced;
 
  ssl on;

  ssl_certificate /etc/letsencrypt/live/replaced.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/replaced.com/privkey.pem;

  root /var/www/wordpress;

  # Add headers to serve security related headers
  # Before enabling Strict-Transport-Security headers please read into this
  # topic first.
  add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
  #
  # WARNING: Only add the preload option once you read about
  # the consequences in https://hstspreload.org/. This option
  # will add the domain to a hardcoded list that is shipped
  # in all major browsers and getting removed from this list
  # could take several months.
  add_header Referrer-Policy "no-referrer" always;
  add_header X-Content-Type-Options "nosniff" always;
  add_header X-Download-Options "noopen" always;
  add_header X-Frame-Options "SAMEORIGIN" always;
  add_header X-Permitted-Cross-Domain-Policies "none" always;
  add_header X-Robots-Tag "none" always;
  add_header X-XSS-Protection "1; mode=block" always; 
 
  fastcgi_hide_header X-Powered-By;

  # Path to the root of your installation root /var/www/html/
  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  location = / {
    # Disable access to the web root, otherwise nginx will show the default site here.
    deny all;

  }
  
  location ^~ /nextcloud {
    # Set max. size of a request (important for uploads to ownCloud)
    client_max_body_size 1G;
    # Besides the timeout values have to be raised in nginx' owncloud config, these values have to be raised for the proxy as well
    proxy_connect_timeout 300;
    proxy_send_timeout 300;
    proxy_read_timeout 300;
    send_timeout 300;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://127.0.0.1:82;
    proxy_redirect off;
    proxy_redirect http://127.0.0.1:82 http://cloud.agmp-iot.com;
  }

  location ^~ /wordpress/ {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://127.0.0.1:83;
    proxy_redirect off;
  }
}

server {
    listen 127.0.0.1:82;
    server_name 127.0.0.1;
 
    # Add headers to serve security related headers
    # Use 'proxy_set_header' (not 'add_header') as the headers have to be passed through a proxy.
    proxy_set_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
    proxy_set_header X-Content-Type-Options nosniff;
    proxy_set_header X-Frame-Options "SAMEORIGIN";
    proxy_set_header X-XSS-Protection "1; mode=block";
    proxy_set_header X-Robots-Tag none;
    proxy_set_header X-Download-Options noopen;
    proxy_set_header X-Permitted-Cross-Domain-Policies none;
 
    # Path to the root of your installation
    root /var/www/;
 
    location = /robots.txt {
       allow all;
       log_not_found off;
       access_log off;
    }

    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you're planning to use this app.
    #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
    #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

    # The following rule is only needed for the Social app.
    # Uncomment it if you're planning to use this app.
    #rewrite ^/.well-known/webfinger /public.php?service=webfinger last;

    location = /.well-known/carddav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }

    location /.well-known/acme-challenge { }

    location ^~ /nextcloud {

      # set max upload size
      client_max_body_size 512M;
      fastcgi_buffers 64 4K;

      # Enable gzip but do not remove ETag headers
      gzip on;
      gzip_vary on;
      gzip_comp_level 4;
      gzip_min_length 256;
      gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
      gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

      # Uncomment if your server is build with the ngx_pagespeed module
      # This module is currently not supported.
      #pagespeed off;

      location /nextcloud {
        rewrite ^ /nextcloud/index.php;
      }

      location ~ ^\/nextcloud/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
        deny all;
      }
      location ~ ^\/nextcloud/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;
      }

      location ~ ^\/nextcloud/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
        fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
        set $path_info $fastcgi_path_info;
        try_files $fastcgi_script_name =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param HTTPS on;
        # Avoid sending the security headers twice
        fastcgi_param modHeadersAvailable true;
        # Enable pretty urls
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
      }
 
      location ~ ^\/nextcloud/(?:updater|oc[ms]-provider)(?:$|\/) {
        try_files $uri/ =404;
        index index.php;
      }

      # Adding the cache control header for js, css and map files
      # Make sure it is BELOW the PHP block
      location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /nextcloud/index.php$request_uri;
        add_header Cache-Control "public, max-age=15778463";
        # Add headers to serve security related headers (It is intended to
        # have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into
        # this topic first.
        #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
        #
        # WARNING: Only add the preload option once you read about
        # the consequences in https://hstspreload.org/. This option
        # will add the domain to a hardcoded list that is shipped
        # in all major browsers and getting removed from this list
        # could take several months.
        add_header Referrer-Policy "no-referrer" always;
        add_header X-Content-Type-Options "nosniff" always;
        add_header X-Download-Options "noopen" always;
        add_header X-Frame-Options "SAMEORIGIN" always;
        add_header X-Permitted-Cross-Domain-Policies "none" always;
        add_header X-Robots-Tag "none" always;
        add_header X-XSS-Protection "1; mode=block" always;

        # Optional: Don't log access to assets
        access_log off;
      }

      location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
        try_files $uri /nextcloud/index.php$request_uri;
        # Optional: Don't log access to other assets
        access_log off;
      }
    }
}

server {
   listen 127.0.0.1:83;
   server_name 127.0.0.1;

   root /var/www/;
	
   location ^~ /wordpress {		
      index index.php;
 
      location /wordpress {
	  try_files $uri $uri/ /wordpress/index.php$is_args$args;
      }
 
      location = /wordpress/favicon.ico {
	  log_not_found off;
	  access_log off;
      }
 
      location = /wordpress/robots.txt {
	  allow all;
	  log_not_found off;
	  access_log off;
      }
 
      location ~ \.php$ {
	  try_files $uri =404;
	  fastcgi_split_path_info ^(.+\.php)(/.+)$;
	  include fastcgi_params;		
	  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	  fastcgi_param PATH_INFO $fastcgi_path_info;
	  fastcgi_pass php-handler;
	  fastcgi_connect_timeout 60;
	  fastcgi_index index.php;
          fastcgi_param REMOTE_ADDR $http_x_real_ip;
	  fastcgi_param PHP_VALUE "open_basedir=/var/www/wordpress:/tmp/
	  upload_max_filesize = 1G
	  post_max_size = 1G
	  max_execution_time = 3600";
      }
 
      location ~* /wordpress/\.(js|css|png|jpg|jpeg|gif|ico)$ {
	  expires max;
	  log_not_found off;
      }
   }
}

Hello,
Are there logs into Nginx log (/var/log/error.log) or Php log (in /var/log) ?

NGINX log:

2020/06/06 16:11:56 [error] 6174#6174: *955 FastCGI sent in stderr: "PHP message: PHP Warning:  file_exists(): open_basedir restriction in effect. File(/var/www/nextcloud/config/config.php) is not within the allowed path(s): (/var/www/wordpress:/tmp/) in /var/www/nextcloud/lib/private/Config.php on line 201PHP message: PHP Warning:  realpath(): open_basedir restriction in effect. File(/var/www/nextcloud/index.php) is not within the allowed path(s): (/var/www/wordpress:/tmp/) in /var/www/nextcloud/lib/base.php on line 149PHP message: PHP Warning:  file_exists(): open_basedir restriction in effect. File(/var/www/nextcloud/apps) is not within the allowed path(s): (/var/www/wordpress:/tmp/) in /var/www/nextcloud/lib/base.php on line 210PHP message: PHP Warning:  file_exists(): open_basedir restriction in effect. File(/var/www/nextcloud/../apps) is not within the allowed path(s): (/var/www/wordpress:/tmp/) in /var/www/nextcloud/lib/base.php on line 212" while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: "GET /nextcloud/apps/files/ HTTP/1.0", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "replacedcom"
2020/06/06 16:11:56 [error] 6174#6174: *786 open() "/var/www/favicon.ico" failed (2: No such file or directory), client: 91.89.13.213, server: replacedcom, request: "GET /favicon.ico HTTP/2.0", host: "replacedcom"

PHP log:

[06-Jun-2020 16:25:46] WARNING: [pool www] child 10240 exited on signal 11 (SIGSEGV) after 0.015816 seconds from start
[06-Jun-2020 16:25:46] NOTICE: [pool www] child 10244 started
[06-Jun-2020 16:25:46] WARNING: [pool www] child 10241 exited on signal 11 (SIGSEGV) after 0.015483 seconds from start
[06-Jun-2020 16:25:46] NOTICE: [pool www] child 10245 started

and sometimes I get error “No input file specified” for nextcloud and “502 Bad Gateway” for wordpress. Everything works again after re-starting nginx and php-fpm services and stop working after sometime!! Today I tried re-installing nextcloud and nginx, nginx configuration remains the same. no improvement!

Hey,
Did you try to edit open_basedir un /etc/php/7.x/fpm/php.ini ?

open_basedir = /var/www/nextcloud:/var/www/wordpress:/tmp/

Restart php after this

Hi,

Yes, it seems to be fixing the issue, but additionally i have to provide path to my nextcloud data (since my data folder is in an external drive).

Thank you for the hints! I really appreciate it.

I saw some hint in the link that you shared that we can configure open_basedir via nginx configuration as well. So I have added open_basedir in my nginx configuration like below.

fastcgi_param PHP_VALUE “open_basedir=/var/www/nextcloud/:/tmp/:/media/HDD1/ncdata/
upload_max_filesize = 1G
post_max_size = 1G
max_execution_time = 3600”;

It was missing for nextcloud in my case (as it is not there in nextcloud decu) and was present for wordpress. This will also fix the issue. The basic problem was with missing php “open_basedir”.

Now server issue seems to be resolved. But still I don’t see any files, folders and settings. I tried re-scanning all files via occ files:scan --all, but nothing changed. I might have to re-configure data folder i guess. The files stil exists in my physical drive. I need to figure out a solution for this now!