Hello,

I am in the process of upgrading a site from D7 to Backdrop CMS. Currently, the core/update.php script is failing with many errors about not being able to create config directory / files.

Failed: ConfigStorageException: Failed to write configuration file: ../config/active/system.core.json in ConfigFileStorage->write() (line 1347 of /var/www/html/backdrop1/core/includes/config.inc).

I had configured permissions as instructed in the documentation.

Because of the error above, I tried changing the config directory in settings.php back to be under the files/ subdirectory.

Httpd user is apache : apache and I have tried setting the files/ directory to

myuser : apache 770 (as directed)

myuser : apache 775 

myuser : apache 777 <-- Just to make sure!

apache : apache 770

apache : apache 775

apache : apache 777

None of these options works.

So then I tried creating the hashed config directory and got this error:

The staging configuration directory (./files/config_[hash]/active) could not be found. Please make sure it exists and is properly referenced in settings.php.

After creating and changing owner to apache, I got similar error with the staging directory, so did the same. Then the update.php completes BUT I again get permission errors for each config file. E.g.

Failed: ConfigStorageException: Failed to write configuration file: ./files/config_[hash]/active/system.core.json in ConfigFileStorage->write() (line 1347 of /var/www/html/backdrop1/core/includes/config.inc).

But same permissions works fine for Drupal. What am I missing / how to fix?

Thanks.

Most helpful answers

Where is your settings.php file? In the installation root? Or inside sites/SITE_FOLDER? Typically, in a single-site installation, settings.php is in the root - therefore you have to be sure to correctly indicate the location of the config/active folder in $config_directories['active'] in settings.php

In your first error above, you pasted the path: 

../config/active/system.core.json 

If your settings.php is in the installation root, this will place the config file one level outside the installation root, which doesn't seem correct. 

If your settings.php file is inside sites/SITE_FOLDER (typically a multisite installation), then typically the config folder is in:

./sites/SITE_FOLDER/files/config_HASH/active

You may need to create the sites/SITE_FOLDER/files folder.

The paths you posted above don't seem to match these patterns.

Comments

Where is your settings.php file? In the installation root? Or inside sites/SITE_FOLDER? Typically, in a single-site installation, settings.php is in the root - therefore you have to be sure to correctly indicate the location of the config/active folder in $config_directories['active'] in settings.php

In your first error above, you pasted the path: 

../config/active/system.core.json 

If your settings.php is in the installation root, this will place the config file one level outside the installation root, which doesn't seem correct. 

If your settings.php file is inside sites/SITE_FOLDER (typically a multisite installation), then typically the config folder is in:

./sites/SITE_FOLDER/files/config_HASH/active

You may need to create the sites/SITE_FOLDER/files folder.

The paths you posted above don't seem to match these patterns.

@argiepiano - Hallo again.

settings.php is in the site root directory. There is comment instructions inside the file that suggest for greater security to place the config file outside the webroot. In fact, I copied their suggested location of '../config/active' and '../config/staging'

Later I changed it back to 

$config_directories['active'] = 'files/config_' . md5($database) . '/active';
$config_directories['staging'] = 'files/config_' . md5($database) . '/staging';

which is (I assume) relative to the web root, which is the correct location of the files/ directory.

 

OK, I figured it out after some more web searches.

It's an SELinux problem. The context for those files parent dir allowed apache to read the config dir but not write to it. Fix like this:

$ chcon -R -t httpd_sys_rw_content_t files/config_[hash]/

Though this goes away on restart so will have to find out how to make it sticky.

Now update.php completes though I have a few errors still...

Warning: unserialize() expects parameter 1 to be string, object given in system_update_1018() (line 2010 of /var/www/html/backdrop1/core/modules/system/system.install).

Notice: Trying to access array offset on value of type bool in system_update_1018() (line 2011 of /var/www/html/backdrop1/core/modules/system/system.install).

Notice: Trying to access array offset on value of type bool in system_update_1018() (line 2011 of /var/www/html/backdrop1/core/modules/system/system.install).

Thanks for your help!