Installation wizard failing to accept valid data directory

I am attempting to deploy a new instance using the installation wizard, after having extracted the server archive to a location from which I would expect the application to be invoked through a suitably provisioned environment of PHP.

Unfortunately, I am facing unexpected difficulties.

The following details describe the general environment preconfiguration, which I would expect to provide for the installation to proceed smoothly, as well as the difficulties:

  • Debian 13 is the operating system of the web server, and it has been freshly installed.

  • The server consists of Apache 2.4 for serving applications, ngnix for managing virtual domains, and a PHP 8.5 using FPM for executing the application.

  • The environment has already been provisioned with basic prerequisites, such as the required extensions of PHP, as well as Redis and MariaDB.

  • Directory /www/appdata exists and is owned by root, and is world readable and navigable.

  • Directory /www/appdata/nextcloud exists and is owned by user www, and is world readable and navigable.

  • The web server executes as user www.

  • In the installation wizard, Data folder has been populated with the value /www/appdata/nextcloud.

  • When the wizard is prompted to proceed with installation, it returns the following error:

    Cannot create or write into the data directory /www/appdata/nextcloud

  • The following commands have been attempted, for testing,

    • runuser -u www -- touch /www/appdata/nextcloud/myfile
    • runuser -u www -- mkdir /www/appdata/nextcloud/mydir

    Both commands succeed, and after each completing, the expected new entry exists, is owned by user www, and is world readable and navigable.

Hopefully, someone may notice whatever I have overlooked or misunderstand.

Where did you install PHP 8.5 from? Debian 13 provides php8.4, no php8.5. I know there are third-party providers, but it would be helpful to know which one you used.

It’s a rather unusual DocumentRoot. /var/www/html is better known and more widely used.

  • Have you configured open_basedir correctly? Maybe you have a default configuration, which prohibit writing to /www/appdata/nextcloud.
  • Have you checked your Systemd configuration? Your PHP package may include a ProtectSystem= and ReadWritePaths= configuration that does not allow writing to non default document roots.

The documentation for your PHP package may specify which directory is allowed by default.

Thank you for sharing your thoughts.

No value is assigned for open_basedir, as can be confirmed from reviewing either the contents of php.ini or the output of php_info().

The software stack is an administrative panel, providing an automated LAMP stack. It manages the installation of software to be operated in the stack. Thus, despite the official repositories, from the operating system, lagging slightly in terms of software versions, preparing PHP 8.5 within the environment has been straightforward..

As important background, I already administrate a functional instance of Nextcloud, operating within a different instance of the same stack. However, the existing system no longer provides suitably recent software components, and meanwhile, an in-place update of the system is not feasible under the circumstances.

The strategy being attempted, therefore, is to migrate from the previous system to a new system, after validating the new environment as capable of correctly operating Nextcloud. Thus, the most immediate objective is simply for the new system to be shown serving some functional instance of Nextcloud.

The directory, as I would understand, is a data directory, not a document root. Regardless, though the chosen location may be unconventional, it should be, and in the past has been, fully compatible with Nextcloud.

Create the following PHP script:

<?php
$path = '/www/appdata/nextcloud/testfile';

if (file_put_contents($path, 'test123') !== false) {
    echo "OK\n";
} else {
    echo "Error writing\n";
}

And open it in the browser using the setup you described (not via the CLI). Was /www/appdata/nextcloud/testfile written successfully?

Your test script has generated the following output:

Warning: file_put_contents(): open_basedir restriction in effect. File(/www/appdata/nextcloud/testfile) is not within the allowed path(s): (/www/wwwroot/nextcloud/:/tmp/) in /www/wwwroot/nextcloud/_testfile.php on line 4

Warning: file_put_contents(/www/appdata/nextcloud/testfile): Failed to open stream: Operation not permitted in /www/wwwroot/nextcloud/_testfile.php on line 4
Error writing

It is quite surprising, though, since the output of phpinfo() reports that open_basedir has been assigned no value.

The means of resolving to the general problem seem quite unclear.

Incidentally, the script is successful, even when invoked through the same distribution of PHP, only from the command line instead of through the web server.

I have finally now succeeded in invoking your test case through the web server.

The administrative utilities, that manage the LAMP stack, provide a toggle called Anti-XSS attack.

The option is enabled by default, but disabling removes the restrictions related to open_basedir.

Now I must try to understand the vulnerability introduced by disabling the option, and the possibility of remaining well protected while still permitting the necessary access by the application to the designated location.

Why don’t you use the DocumentRoot that your “administrative utility” provides/configured for you? /www/wwwroot/nextcloud/ apparently, and not /www/appdata/nextcloud.

Open Basdir settings can be defined in a global config file, in a user php.ini/user.ini file, or even in the web server configuration when PHP is called. And OpenBase is just one of them… It’s quite possible that other security features are also in place. If you want to deliberately deviate from the standard set by “administrative utility” (whatever that is), it probably makes more sense to ask about it in the “administrative utility” forum, instead of here :slight_smile:

Keeping the application code separate from the stored files has been necessary in various scenarios of administrating Nextcloud. It is not always possible for both to be maintained on the same volume.