Run Nextcloud with PHP-FPM chroot

Support Intro:

Nextcloud version: 17.0.2
Operating system and version: Ubuntu 16.04.6 LTS
Apache or nginx version: nginx/1.15.8
PHP version: 7.3.11

The issue you are facing:

[error] 8983#8983: *5531 FastCGI sent in stderr: "PHP message: PHP Fatal error:  require_once(): Failed opening required 'support/appinfo/app.php' (include_path='.') in /data/lib/private/legacy/app.php on line 265" while reading response header from upstream, client: x.x.x.x, server: sub.example.com, request: "GET /csrftoken HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm-u000.sock:", host: "sub.example.com"

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

Steps to replicate it:

  1. Prepare PHP-FPM chroot environment (similar to this tutorial)
  2. Install Nextcloud and complete the setup
  3. End with a blank page and the above error

Detailed explanation:

I am trying to run a NC instance within a PHP-FPM chroot. As far as I have seen/searched this forum / the internet there is no tutorial nor anyone has really tried or documented this yet (?). Nonetheless I tried running NC within the above mentioned chroot environment to no avail. The setup process successfully runs through but then sends you to a blank page.

Within nginx error log you see the above error which indicates that NC can’t find it’s app folder properly which likely is caused by the chroot environment which shifts the $document_root path and creates the above error (?).

Manually adding ‘apps’ in /data/lib/private/legacy/app.php on line 265 to fix the path succeeds in loading the login page but makes the login fail as it now appends all apps (even files) with ‘apps’ which obviously is wrong.

What I have found so far is that you can manually set the apps_paths within config.php, which I did:

  'apps_paths' => array(
        array(
                'path'=> '/data/apps',
                'url' => '/apps',
                'writable' => true,
        ),
     ),

This does not help either.

Extra information:

My chroot environment looks like this:

/var/www/u000/
└── [drwxr-xr-x u000 u000] chroot
    ├── [drwxr-xr-x u000 u000]  data # nextcloud instance located here
    ├── [drwxr-xr-x u000 u000]  log
    └── [drwxr-xr-x u000 u000]  tmp

PHP-FPM can only see things within chroot so /data is NC and can be seen + accessed.

/var/www/u000/chroot/data is not acessible from PHP-FPM side (!).


Can anyone point me how to get NC to find it’s own apps folder within my chroot environment?

Also is there any good documentation on how to run NC within a chroot environment?