Internal server error without error output in any log files -> hard to locate problem

Hi,

i’ve installed Nextcloud after the guide in the ArchLinux Wiki.
Calling the website results in an Internal server error.
It’s hard to troubleshoot or search errors online, if I cannot get any output in the error log.
I tried to enable error_logging and display_errors in all php.ini (nextclouds, php-fpm) files and also activated debug mode in nextcloud config.php. No luck.

I’m running out of options and don’t know what to do next.

One thing I tried to check if the php-fpm is working was by adding a print(ā€œtestā€); and Exit; to the index.php file of nextcloud before the nextcloud code gets executed.
Apache/PHP returned successfully and even wrote to the log:

[Mon Apr 10 23:41:55.209261 2023] [proxy_fcgi:error] [pid 167285:tid 139919984924352] [client xxx.xxx.xxx.xx:63747] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Error: Typed static property OC::$server must not be accessed before initialization in /usr/share/webapps/nextcloud/index.php:73\nStack trace:\n#0 {main}\n  thrown in /usr/share/webapps/nextcloud/index.php on line 73'

Things I suspected and checked:

  • Permission problem? User http needs access to files/folders where user nextcloud has the only perms
  • PHP and PHP-LEGACY are both installed. Are extensions missing? Doesn’t look so.
  • Nextcloud is having a problem with just an IP address (no hostname)? Or the Apache vhost config for it?

More details:
Setup is Apache + PHP (legacy) + FPM

/var/log/nextcloud/nextcloud.log
– empty –

Apache vhost:

<VirtualHost 123.4.567.89:80>
    DocumentRoot "/srv/http/default"
    ErrorLog "/var/log/httpd/defaultfolder-error_log"
    CustomLog "/var/log/httpd/defaultfolder-access_log" common
    #nextcloud config
    Alias /nextcloud /usr/share/webapps/nextcloud
    <Directory /usr/share/webapps/nextcloud>
       Require all granted
       AllowOverride All
       Options FollowSymLinks MultiViews
       DirectoryIndex index.php index.html
       <IfModule mod_dav.c>
           Dav off
       </IfModule>
       <FilesMatch \.php$>
           SetHandler "proxy:unix:/run/php-fpm-legacy/nextcloud.sock|fcgi://nextcloud/"
       </FilesMatch>
    </Directory>
</VirtualHost>

/etc/webapps/nextcloud/config/config.php

<?php
$CONFIG = array (
  'datadirectory' => '/var/lib/nextcloud/data',
  'log_type' => 'errorlog',
  'debug' => false,
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/usr/share/webapps/nextcloud/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/lib/nextcloud/apps',
      'url' => '/wapps',
      'writable' => true,
    ),
  ),
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '123.4.567.89'
  ),
  'dbtype' => 'pgsql',
  'version' => '26.0.0.11',
  'overwrite.cli.url' => 'http://123.4.567.89',
  'htaccess.RewriteBase' => '/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => '/run/postgresql:9090',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'xxx',
  'installed' => true,
  'instanceid' => 'xxx',
  'memcache.local' => '\OC\Memcache\APCu',
  'memcache.distributed' => '\OC\Memcache\Redis',
  'memcache.locking' => '\OC\Memcache\Redis',
  'redis' => [
       'host' => '/run/redis/redis.sock',
       'port' => 6345,
       'dbindex' => 0,
       'password' => '',
       'timeout' => 1.5,
  ],
);

/var/log/php-fpm-legacy/access/nextlcoud.log (always the same error)
2023-04-10T23:03:29+0200 -: "GET /nextcloud/index.php" 500 //usr/share/webapps/nextcloud/index.php 12.268 2048 0.00%

I also checked other logs like redis, postgresql, but no errors detectable.

Help is highly appreciated. Thank you.

Still no idea how to approach this. Or what points I can attack to trigger a meaningful response.

Any ideas?

You should only use one of both. If you use both side by side, you’ve opened all the doors to a version mess.
I would recommend uninstalling php and getting the whole thing up and running with php-legacy first.

I removed PHP. It had no effect.
As I already stated, the FPM-PHP seems to work because it interprets .php files as I forced an output.

No idea what to do next.

So there we are. That is not correct, since php-fpm (I guess your FPM-PHP was a typo) is the wrong version, it is php8.2. In your case, you should use php-legacy-fpm. Every php-package that does not contain the ā€˜legacy’ in its name should be removed first.

The confusion of different php versions is one of the main causes of errors on this forum.

could you explain, what you understands under ā€œforcing an outputā€? What did you do exactly? I could give you lots of examples of output that you could ā€œforceā€ without them telling you anything about underlying errors because of version mismatch.

No. With FPM-PHP I meant FPM in general. That I use php-legacy-fpm should be clear from my first post.
I carefully checked everything is legacy. Modules are installed. Open_basedir has the neccessary paths. Looked into troubleshooting guides. It’s so odd.

With forced I mean, that at the entry point of the nextcloud web application I can output PHP code like print(ā€œā€¦ā€) or phpinfo() in the same index.php script, where the nextcloud app gets instanciated.
So the surroundings seems working.

So the only thing I could think of to try would be in Apache vhost.conf:

can be removed, since that is already done by .htaccess

Try instead of this:

this way (2 changes!):

       <FilesMatch ".+\.php$">
           SetHandler "proxy:unix:/run/php-fpm-legacy/nextcloud.sock|fcgi://localhost"
       </FilesMatch>

If that doesn’t help, I can’t think of anything else so quickly, since I’m not sitting at the machine myself and basically only execute Arch in my head.

This doesn’t help you troubleshoot directly, but in the interest of potentially saving you (and us) some time and headache…

You picked an extremely challenging - and nonstandard - way to deploy NC.

It’s going to be extremely fragile unless you really know what you’re doing with all the pieces involved (and even then).

So I have to ask: Is there any particular reason you chose this install path? Is there something you’re getting out of this deployment path you wouldn’t be getting through more a more conventional and/or less labor intensive (and manual and error prone - and ultimately extremely fragile to maintain, update, debug - even if you do manage to get it working initially)?

I’m a big fan of the Arch Linux wiki material, but that NC one is crazy!

Have you considered either an NC All-In-One or Community Docker deployment instead?

Well, I consider it now.
I’ve set up a nextcloud-PI installation for a friend and thought, integrating the necessary parts into an existing system/environment couldn’t be that of a hassle. Seems to be a mistake. Although I’m not inexperienced with all pieces of the puzzle.

Suitable for me is the nextcloud fpm image?
Integrating already running applications like FAIL2BAN is possible?

Greetings

Guys.
I fixed it.

I started as entry point with the index.php again and just print($ex); until I got an output.
Going down the route of the returned error.
In my case, it said: memcache module not available. But it was.
I then started with returning infos with phpinfo() to investigate why PHP says it isn’t.
There I saw, that config files from a subdirectory /etc/php-legacy/conf.d/ are pulled in last, where memcache was deactivated.
What’s scary is, that nowhere is a kind of inheritanced include-chain, that lets even PHP-FPM pull in the files from this sub directory.

May this help someone else in debugging his installation!

Glad to hear you got it working!

1 Like