Recreated data directory after disk crash, Internal Server Error

Nextcloud version (eg, 12.0.2):
12.0.3.3

Operating system and version (eg, Ubuntu 17.04):
Arch Linux, latest stable release

Apache or nginx version (eg, Apache 2.4.25):
Apache 2.4.27

PHP version (eg, 7.1):
7.1.10

The issue you are facing:

My installation uses local authentication. My installation path is /usr/share/webapps/owncloud, because I upgraded from previous versions of owncloud, until I migrated to nextcloud successfully.
Inside that directory, resides the data directory. That directory uses another disk, just to have enough space to sync all the files I and my clients have on their PCs.
This was working perfectly, until the disk had a serious issue, and needed to be replaced.
The backups of the data directory had some issues, so I had to leave the data directory as it was, empty, starting to sync files again, using “tar” on the PCs.
The issues I’m facing is that they can sync files, but cannot access the web interface.
Even the admin user cannot, and every time we try to access the web interface we receive the message:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

Checking the logs (nextcloud.log) I can see this:

{"reqId":"tu0wiepr13KmMkgExghM","level":3,"time":"2018-02-08T02:42:12+00:00","remoteAddr":"192.168.0.132","user":"noexiste","app":"core","method":"GET","url":"\/index.php\/apps\/files\/","message":"Exception: {\"Exception\":\"OCP\\\\Files\\\\NotPermittedException\",\"Message\":\"\",\"Code\":0,\"Trace\":\"#0 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/Files\\\/SimpleFS\\\/SimpleFile.php(104): OC\\\\Files\\\\Node\\\\File->delete()\\n#1 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/Template\\\/SCSSCacher.php(252): OC\\\\Files\\\\SimpleFS\\\\SimpleFile->delete()\\n#2 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/Template\\\/SCSSCacher.php(164): OC\\\\Template\\\\SCSSCacher->resetCache()\\n#3 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/Template\\\/SCSSCacher.php(109): OC\\\\Template\\\\SCSSCacher->variablesChanged()\\n#4 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/Template\\\/CSSResourceLocator.php(99): OC\\\\Template\\\\SCSSCacher->process('\\\/usr\\\/share\\\/weba...', 'core\\\/css\\\/server...', 'core')\\n#5 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/Template\\\/CSSResourceLocator.php(56): OC\\\\Template\\\\CSSResourceLocator->cacheAndAppendScssIfExist('\\\/usr\\\/share\\\/weba...', 'core\\\/css\\\/server...')\\n#6 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/Template\\\/ResourceLocator.php(75): OC\\\\Template\\\\CSSResourceLocator->doFind('css\\\/server')\\n#7 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/TemplateLayout.php(225): OC\\\\Template\\\\ResourceLocator->find(Array)\\n#8 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/TemplateLayout.php(170): OC\\\\TemplateLayout::findStylesheetFiles(Array)\\n#9 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/legacy\\\/template.php(205): OC\\\\TemplateLayout->__construct('error', '')\\n#10 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/Template\\\/Base.php(132): OC_Template->fetchPage()\\n#11 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/legacy\\\/template.php(342): OC\\\\Template\\\\Base->printPage()\\n#12 \\\/usr\\\/share\\\/webapps\\\/owncloud\\\/index.php(67): OC_Template::printExceptionErrorPage(Object(OCP\\\\Files\\\\NotPermittedException))\\n#13 {main}\",\"File\":\"\\\/usr\\\/share\\\/webapps\\\/owncloud\\\/lib\\\/private\\\/Files\\\/Node\\\/File.php\",\"Line\":122}","userAgent":"Mozilla\/5.0 (Windows NT 10.0; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Maxthon\/4.9.5.1000 Chrome\/39.0.2146.0 Safari\/537.36","version":"12.0.3.3"}

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

Steps to replicate it:

  1. Access the web interfaces
  2. Use the usual username and password
  3. Receive the mentioned error

The output of your Nextcloud log in Admin > Logging:
Cannot access the web interface.

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

<?php $CONFIG = array ( 'instanceid' => 'ochq4szhhxyy', 'passwordsalt' => 'encrypted_secret', 'secret' => 'another_encrypted_secret', 'trusted_domains' => array ( 0 => 'nube.yyyy.com.ar', ), 'datadirectory' => '/usr/share/webapps/owncloud/data', 'overwrite.cli.url' => 'http://nube.yyyy.com.ar/owncloud', 'dbtype' => 'mysql', 'version' => '12.0.3.3', 'dbname' => 'owncloud', 'dbhost' => '127.0.0.1', 'dbtableprefix' => 'oc_', 'dbuser' => 'owncloud', 'dbpassword' => 'secret', 'logtimezone' => 'UTC', 'installed' => true, 'memcache.local' => '\\OC\\Memcache\\APCu', 'memcache.distributed' => '\\OC\\Memcache\\Memcached', 'memcached_servers' => array ( 0 => array ( 0 => 'localhost', 1 => 11211, ), ), 'appstore.experimental.enabled' => true, 'mail_from_address' => 'cloud', 'mail_smtpmode' => 'smtp', 'mail_domain' => 'yyyy.com.ar', 'mail_smtpauthtype' => 'LOGIN', 'mail_smtpauth' => 1, 'mail_smtphost' => 'xxxx.yyyy.com.ar', 'mail_smtpport' => '25', 'mail_smtpname' => 'cloud@yyyy.com.ar', 'mail_smtppassword' => 'secret', 'maintenance' => false, 'loglevel' => 2, 'updater.secret' => 'encrypted_secret', );

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

Nothing related to this error, just the logs from the clients, syncing:

10.150.110.49 - user@yyyy.com.ar [08/Feb/2018:01:04:24 -0300] "PROPFIND /owncloud/remote.php/webdav/Desktop HTTP/1.1" 207 374 10.150.110.49 - user@yyyy.com.ar [08/Feb/2018:01:04:24 -0300] "PROPFIND /owncloud/remote.php/webdav/Documents HTTP/1.1" 207 376 10.150.110.49 - user@yyyy.com.ar [08/Feb/2018:01:04:24 -0300] "PROPFIND /owncloud/remote.php/webdav/Photos HTTP/1.1" 207 373 10.150.110.49 - user@yyyy.com.ar [08/Feb/2018:01:04:24 -0300] "PROPFIND /owncloud/remote.php/webdav/Music HTTP/1.1" 207 372 10.150.110.49 - user@yyyy.com.ar [08/Feb/2018:01:04:24 -0300] "PROPFIND /owncloud/remote.php/webdav/Videos HTTP/1.1" 207 373

The solution to this issue was to disable the not used storages (select * from oc_storages, then delete from oc_storages where numeric_id=‘xxx’), and to truncate oc_filecache (truncate oc_filecache), and Internal server error went out.
Hope this helps somebody.
Thanks, and best regards,
HeCSa.