Attempting Login leads to Internal Server Error, possibly because of php ldap

Nextcloud version: 24.0.9
Operating system and version: Ubuntu 20.04
Apache version: Apache/2.4.41
PHP version: PHP 7.4.33

The issue you are facing:

This is the first time I’ve seen this error.

I followed this article to get my server accessible from the internet, because I have a DS-Lite connection.

My homeserver sits behind a ssh tunnel over a server on the internet, because I have no ipv4 address at home anymore.

The setup is now, as I understand it:

INTERNET → mydomain.de → internet-server → (ssh-tunnel) → home-server (with certbot certificate for mydomain.de)

I can load a test website with https fine, and also get to the nextcloud login screen, but when entering my credentials, I get the " Internal Server Error. The server was unable to complete your request. " message.

The output of your Nextcloud log in Admin > Logging reads

Debug    extract            /appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.                                                                       2023-05-21T10:33:35+00:00 

  Warning  no app in context  Failed to parse mimetypemapping.json: Syntax error   

I also sometimes get

Error    PHP                PHP Startup: Unable to load dynamic library 'php_ldap.so' (tried: /usr/lib/php/20190902/php_ldap.so (/usr/lib/php/20190902/php_ldap.so: cannot open shared object file: No such    2023-05-21T10:45:09+00:00 
                              file or directory), /usr/lib/php/20190902/php_ldap.so.so (/usr/lib/php/20190902/php_ldap.so.so: cannot open shared object file: No such file or directory)) at Unknown#0                                     

The output of your config.php file in /path/to/nextcloud:

<?php
$CONFIG = array (
  'instanceid' => 'XXXXXXXXXXX',
  'passwordsalt' => 'XXXXXXXXXXXX',
  'secret' => 'XXXXXXXXXX',
  'trusted_domains' => 
  array (
    0 => 'LOCAL IP PLACEHOLDER',
    1 => 'REMOTE IP PLACEHOLDER',
    2 => 'server',
    3 => 'mydomain.de',
    4 => 'www.mydomain.de'
  ),
  'datadirectory' => '/mnt/nextcloud_nas/data',
  'dbtype' => 'mysql',
  'version' => '24.0.9.2',
  'overwrite.cli.url' => 'http://XXXXXXXXX/nextcloud',
  'htaccess.RewriteBase' => '/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'XXXXXXXX',
  'dbpassword' => 'XXXXXXXXXXXX',
  'installed' => true,
  'maintenance' => false,
  'mysql.utf8mb4' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'theme' => '',
  'loglevel' => 0,
  'app_install_overwrite' => 
  array (
    0 => 'documentserver_community',
    1 => 'pride',
    2 => 'sharerenamer',
  ),
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'updater.release.channel' => 'stable',
  'default_phone_region' => '1974',
);

The output of your Apache error log in /var/log/____:

PHP Warning:  PHP Startup: Unable to load dynamic library 'php_ldap.so' (tried: /usr/lib/php/20190902/php_ldap.so (/usr/lib/php/20190902/php_ldap.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/php_ldap.so.so (/usr/lib/php/20190902/php_ldap.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[Sun May 21 12:04:42.074592 2023] [mpm_prefork:notice] [pid 4172] AH00163: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Sun May 21 12:04:42.074661 2023] [core:notice] [pid 4172] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 21 12:11:09.516748 2023] [mpm_prefork:notice] [pid 4172] AH00169: caught SIGTERM, shutting down
PHP Warning:  PHP Startup: Unable to load dynamic library 'php_ldap.so' (tried: /usr/lib/php/20190902/php_ldap.so (/usr/lib/php/20190902/php_ldap.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/php_ldap.so.so (/usr/lib/php/20190902/php_ldap.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[Sun May 21 12:11:09.644687 2023] [mpm_prefork:notice] [pid 4440] AH00163: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Sun May 21 12:11:09.644752 2023] [core:notice] [pid 4440] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 21 12:51:12.526329 2023] [php7:error] [pid 4450] [client 127.0.0.1:38342] script '/var/www/html/status.php' not found or unable to stat

PASTE HERE


Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

{"reqId":"bn21biw6EyU9JN7w2hEN","level":3,"time":"2020-05-28T12:01:05+00:00","remoteAddr":"192.168.178.58","user":"--","app":"PHP","method":"POST","url":"/nextcloud/index.php","message":"mkdir(): No such file or directory at /var/www/nextcloud/lib/private/Setup.php#312","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36","version":""}
{"reqId":"Fzyd7AyTuBZHiq0DxQAp","level":3,"time":"2020-05-28T12:01:48+00:00","remoteAddr":"192.168.178.58","user":"--","app":"PHP","method":"POST","url":"/nextcloud/index.php","message":"mkdir(): No such file or directory at /var/www/nextcloud/lib/private/Setup.php#312","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36","version":""}
{"reqId":"YY8JMNu3bPzMvKigcs0N","level":3,"time":"2020-05-28T12:02:28+00:00","remoteAddr":"192.168.178.58","user":"--","app":"PHP","method":"POST","url":"/nextcloud/index.php","message":"mkdir(): No such file or directory at /var/www/nextcloud/lib/private/Setup.php#312","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36","version":""}
{"reqId":"8ogvUbhCUuT5eTCDgGmF","level":3,"time":"2020-05-28T12:04:12+00:00","remoteAddr":"192.168.178.58","user":"--","app":"PHP","method":"POST","url":"/nextcloud/index.php","message":"mkdir(): No such file or directory at /var/www/nextcloud/lib/private/Setup.php#312","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36","version":""}

Are you saying this NC setup functioned just fine prior to setting up this tunnel? If you can’t login, how did you get that output from Admin->Logging?

  • What happens if you try to access your Nextcloud locally via it’s IP address or similar? (I would expect it to fail based on what I see above, but still a good idea to simplify what we’re debugging)

  • Did you make any PHP changes or package changes? Your php.ini is referencing the ldap extension. You will need to either install it or remove the extension for it in all of your PHP ini files.

  • Can you confirm the timestamps of the nextcloud.log entries you provided match up with when you are reproducing the login behavior? (The year suggests the ones provided have nothing to do with this)

Yes, I was able to log in to the NC setup via the local IP address before, but not from the outside (my internet provider changed and with the new provider I no longer have an ipv4 address, which necessitated the tunnel.

I probably mixed things up with the Admin - Logging Logs, these were obtained by running
sudo -u www-data php occ log:watch

I just reran that and attempted a login locally:

  Debug    extract            /appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.                                                                       2023-05-21T13:15:16+00:00 

  Warning  no app in context  Failed to parse mimetypemapping.json: Syntax error                                                                                                                                 2023-05-21T13:15:16+00:00 

  Debug    extract            /appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.                                                                       2023-05-21T13:15:23+00:00 

  Warning  no app in context  Failed to parse mimetypemapping.json: Syntax error                                                                                                                                 2023-05-21T13:15:23+00:00 

  Debug    extract            /appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.                                                                       2023-05-21T13:15:23+00:00 

  Warning  no app in context  Failed to parse mimetypemapping.json: Syntax error                                                                                                                                 2023-05-21T13:15:23+00:00

and again via the url:

  Debug    extract            /appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.                                                                       2023-05-21T13:16:13+00:00 

  Warning  no app in context  Failed to parse mimetypemapping.json: Syntax error                                                                                                                                 2023-05-21T13:16:13+00:00 

  Warning  no app in context  Failed to parse mimetypemapping.json: Syntax error                                                                                                                                 2023-05-21T13:16:17+00:00 

  Debug    no app in context  OC\AppFramework\Middleware\Security\Exceptions\NotLoggedInException: Current user is not logged in at .../Middleware/Security/SecurityMiddleware.php line 153                      2023-05-21T13:16:17+00:00 
                                                                                                                                                                                                                                           
                              0. lib/private/AppFramework/Middleware/MiddlewareDispatcher.php line 97                                                                                                                                      
                                 OC\AppFramework\Middleware\Security\SecurityMiddleware->beforeController(                                                                                                                                 
                                                                                                                                                                                                                                           
                                 )                                                                                                                                                                                                         
                              1. lib/private/AppFramework/Http/Dispatcher.php line 125                                                                                                                                                     
                                 OC\AppFramework\Middleware\MiddlewareDispatcher->beforeController(                                                                                                                                        
                                                                                                                                                                                                                                           
                                 )                                                                                                                                                                                                         
                              2. lib/private/AppFramework/App.php line 172                                                                                                                                                                 
                                 OC\AppFramework\Http\Dispatcher->dispatch(                                                                                                                                                                
                                                                                                                                                                                                                                           
                                 )                                                                                                                                                                                                         
                              3. lib/private/Route/Router.php line 298                                                                                                                                                                     
                                 OC\AppFramework\App::main(                                                                                                                                                                                
                                                                                                                                                                                                                                           
                                 )                                                                                                                                                                                                         
                              4. lib/base.php line 1030                                                                                                                                                                                    
                                 OC\Route\Router->match(                                                                                                                                                                                   
                                                                                                                                                                                                                                           
                                 )                                                                                                                                                                                                         
                              5. index.php line 36                                                                                                                                                                                         
                                 OC::handleRequest(                                                                                                                                                                                        
                                                                                                                                                                                                                                           
                                 )                                                                                                                                                                                                         

  Debug    extract            /appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.                                                                       2023-05-21T13:16:17+00:00 

  Warning  no app in context  Failed to parse mimetypemapping.json: Syntax error                                                                                                                                 2023-05-21T13:16:17+00:00 

  Debug    extract            /appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.                                                                       2023-05-21T13:16:17+00:00 

  Warning  no app in context  Failed to parse mimetypemapping.json: Syntax error                                                                                                                                 2023-05-21T13:16:17+00:00 

  Debug    extract            /appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.                                                                       2023-05-21T13:16:17+00:00 

  Warning  no app in context  Failed to parse mimetypemapping.json: Syntax error                 

(after getting to the error screen, I pressed F5, which generated the additional error messages compared to the local login attempt).

Yes, if I try to access the NC via the local IP, I get the same error behavior.

I did run “apt update” while setting up the tunnel. I just checked if I have ldap installed, and it seems to be on the system:

sudo apt-get install php-ldap
[sudo] password for user: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
php-ldap is already the newest version (2:8.2+93+ubuntu18.04.1+deb.sury.org+2).

Or do I have to look at nextcloud specifically for this extension? (as in, ldap is on the system, but NC is not using it?) Other than that, I’m not aware that I changed anything php-wise.

I’ve checked, and the timestamps in the nextcloud.log are unrelated. My IP address is different to the one shown there, so I think those are just old logs. That is everything in my data/nextcloud.log file though.

The PHP warning states that a library file is missing which is required by the PHP module. By running the following command you should be able to identify the missing component:

ldd /usr/lib/php/20190902/php_ldap.so

I tried running the ldd command you suggested, but the file php_ldap.so does not exist at all. I think it might have something to do with the newly installed SSL certificates, but I’m at a loss right now.