Internal server error after reenabling gallery app

SOLUTION FOUND. I JUST LEAVE THIS IN CASE SOMEONE ELSE HAS A SIMILAR PROBLEM.

System information
Ubuntu 16.04 LTS Server
MySQL 5.7.16
PHP 7.0.8
Nginx 1.10.0
Nextcloud 11 stable

Is this the first time you’ve seen this error?:
Yes

Can you reliably replicate it? (If so, please outline steps):
I dont get that far

The issue you are facing:
After disabling and enabling the gallery app the web interface stopped responding. I got an internal server error. One hint might give us the error when checking for enabled apps (see below). It seems to be a problem with the gallery app. Half a year ago I installed the gallery app from git. It might be that after the last NC upgrade things broke as I noticed that the gallery app appears twice in the NC interface. That’s why I tried to disable and re-enable it (without thinking about the fact that I updated it via git half a year ago).

The output of your Nextcloud log in Admin > Logging:
I cant access this log file via web interface. >> Where is this log, when I have access to the web interface? I tried google, but could not find it.

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

<?php
$CONFIG = array (
  'updatechecker' => false,
  'instanceid' => 'XXXXXX',
  'passwordsalt' => 'XXXXXX+VF/ai',
  'secret' => 'XXX/XXXXX',
  'trusted_domains' =>
  array (
    0 => '192.168.10.11',
    1 => 'XXXX',
    2 => 'XXXXX',
  ),
  'datadirectory' => '/home/media2/owncloud',
  'overwrite.cli.url' => 'http://192.168.10.11/owncloud',
  'dbtype' => 'mysql',
  'version' => '11.0.2.7',
  'dbname' => 'owncloud',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'XXX',
  'dbpassword' => 'XXXX+',
  'logtimezone' => 'UTC',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'asset-pipeline.enabled' => true,
  'loglevel' => 1,
  'maintenance' => false,
  'theme' => '',
  'updater.release.channel' => 'stable',
  'mail_smtpmode' => 'sendmail',
  'mail_from_address' => 'cloud',
  'mail_domain' => 'XXXX.XXXX',
  'mail_smtphost' => 'XXX.XXXXX.XXX',
  'mail_smtpport' => '25',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'XXX@XXX.XXX',
  'mail_smtppassword' => 'XXX',
);

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

nginx and nextcloud-error log are nearly empty.

/var/log/nginx/error.log

2017/03/24 01:41:26 [info] 730#730: Using 32768KiB of shared memory for push module in /etc/nginx/nginx.conf:63
2017/03/24 01:41:26 [warn] 730#730: conflicting server name "torrent.XXX.network" on 0.0.0.0:80, ignored
2017/03/24 01:41:26 [warn] 730#730: conflicting server name "torrent.XXX.network" on 0.0.0.0:443, ignored
2017/03/24 01:41:26 [warn] 734#734: conflicting server name "torrent.XXX.network" on 0.0.0.0:80, ignored
2017/03/24 01:41:26 [warn] 734#734: conflicting server name "torrent.XXX.network" on 0.0.0.0:443, ignored

/var/log/php7.0-fpm.log
- empty -

/var/log/nginx/nextcloud.error.log
- empty -

/var/log/nginx/nextcloud.error.log.1

2017/03/20 02:30:59 [error] 1601#1601: *15868 access forbidden by rule, client: 66.133.109.36, server: cloud.mogul.network, request: "GET /.well-known/acme-challenge/XXXXX HTTP/1.1", host: "cloud.XXXX.network", referrer: "http://cloud.XXXX.network/.well-known/acme-challenge/obQ_FGqm0zXMFcWy1uQOqjnnYCCJ15gzJBZF8zyWgO4"
2017/03/20 02:31:37 [error] 1601#1601: *15889 access forbidden by rule, client: 66.133.109.36, server: cloud.mogul.network, request: "GET /.well-known/acme-challenge/XXXXX-qmjk_pIDVikItGh4XYd9o HTTP/1.1", host: "cloud.XXXX.network", referrer: "http://cloud.XXXX.network/.well-known/acme-challenge/XXXX-qmjk_pIDVikItGh4XYd9o"

Enabled Apps
I get an error when trying to fetch the enabled apps. Maybe that helps us to go further.

sudo -u www-data php occ app:list
[sudo] Passwort für XXX:
An unhandled exception has been thrown:
OCP\AutoloadNotAllowedException: Autoload path not allowed: /var/www/nextcloud/apps/gallery/appinfo/application.php in /var/www/nextcloud/lib/autoloader.php:141
Stack trace:
#0 /var/www/nextcloud/lib/autoloader.php(165): OC\Autoloader->isValidPath('/var/www/nextcl...')
#1 [internal function]: OC\Autoloader->load('OCA\\Gallery\\App...')
#2 /var/www/nextcloud/apps/gallery.bak/appinfo/app.php(19): spl_autoload_call('OCA\\Gallery\\App...')
#3 /var/www/nextcloud/lib/private/legacy/app.php(214): require_once('/var/www/nextcl...')
#4 /var/www/nextcloud/lib/private/legacy/app.php(155): OC_App::requireAppFile('gallery.bak')
#5 /var/www/nextcloud/lib/private/legacy/app.php(125): OC_App::loadApp('gallery.bak')
#6 /var/www/nextcloud/lib/private/Console/Application.php(103): OC_App::loadApps()
#7 /var/www/nextcloud/console.php(89): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')

Solution
From the last git adventure a gallery.bak backup of the old gallery was left in the nextcloud/apps folder. The gallery.bak folder was there in case something goes wrong with the git adventure. Until the last upgrade of NC this folder seemed to be ignored. No it was recognized and give me the above error. I removed the folder and the occ as well as the internal server error are gone.

Enabled Apps

sudo -u www-data php occ app:list
Enabled:
  - activity: 2.4.1
  - admin_audit: 1.1.0
  - comments: 1.1.0
  - dav: 1.1.1
  - direct_menu: 0.10.0
  - federatedfilesharing: 1.1.1
  - federation: 1.1.1
  - files: 1.6.1
  - files_downloadactivity: 1.0.1
  - files_external: 1.1.2
  - files_pdfviewer: 1.0.1
  - files_retention: 1.0.1
  - files_sharing: 1.1.1
  - files_texteditor: 2.2
  - files_trashbin: 1.1.0
  - files_versions: 1.4.0
  - files_videoplayer: 1.0.0
  - firstrunwizard: 2.0
  - logreader: 2.0.0
  - lookup_server_connector: 1.0.0
  - nextcloud_announcements: 1.0
  - notifications: 1.0.1
  - password_policy: 1.1.0
  - previewgenerator: 1.0.5
  - provisioning_api: 1.1.0
  - serverinfo: 1.1.1
  - sharebymail: 1.0.1
  - survey_client: 0.1.5
  - systemtags: 1.1.3
  - templateeditor: 0.2
  - theming: 1.1.1
  - twofactor_backupcodes: 1.0.0
  - updatenotification: 1.1.1
  - workflowengine: 1.1.1
Disabled:
  - calendar
  - encryption
  - external
  - files_accesscontrol
  - files_automatedtagging
  - gallery
  - richdocuments
  - spreed
  - user_external
  - user_ldap
  - user_saml

No I was able to enable the gallery app again and everything is fine :slight_smile: