Bogdan Balan Bogdan Balan - 1 year ago 158
Apache Configuration Question

How can I give Drupal 8 access to config files outside the web root?

I just jumped into Drupal 8, and I'm having trouble enabling file-based config in my project. I am using these instructions:

I've followed all the steps, but every time I try to make a config change, I get the following error:

Drupal\Core\Config\StorageException: Failed to create config directory
./../config/active in Drupal\Core\Config\FileStorage->ensureStorage()
(line 72 of /Users/bbalan/Sites/d8project/web/core/lib/Drupal/Core/Config/FileStorage.php).

I think there's something wrong with the paths in my settings.php. The instructions say to use a path outside the web root, probably for security reasons. Here's what I have:

$config_directories = array(
CONFIG_ACTIVE_DIRECTORY => './../config/active',
CONFIG_STAGING_DIRECTORY => './../config/staging',
CONFIG_SYNC_DIRECTORY => './../config/sync',

I set all the config directory permissions to 777, and the active/staging/sync directories have already been created manually (also with 777). Here are the contents of my project folder:

-rw-r--r-- 1 bbalan staff 18046 8 Aug 15:22 LICENSE
-rw-r--r-- 1 bbalan staff 4787 8 Aug 15:22
-rw-r--r-- 1 bbalan staff 2299 8 Aug 17:35 composer.json
-rw-r--r-- 1 bbalan staff 206302 8 Aug 17:35 composer.lock
drwxrwxrwx 6 bbalan staff 204 8 Aug 15:36 config
drwxr-xr-x 4 bbalan staff 136 8 Aug 15:22 drush
-rw-r--r-- 1 bbalan staff 481 8 Aug 15:22 phpunit.xml.dist
drwxr-xr-x 3 bbalan staff 102 8 Aug 15:22 scripts
drwxr-xr-x 42 bbalan staff 1428 8 Aug 17:36 vendor
drwxr-xr-x 19 bbalan staff 646 8 Aug 17:23 web

This is a Drupal 8.1.8 install built with Composer from instructions at . All the Drupal site files are in
. Here's my httpd-vhosts.conf:

<VirtualHost *:80>
ServerName drupal-8.local
ServerAlias drupal-8.local
DocumentRoot /Users/bbalan/Sites/d8project/web/
<Directory /Users/bbalan/Sites/d8project/web/>
Options FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all

Any ideas? Everything works if I move the
dir to a location in the web root (for example,
), but this seems unsafe and counter to the instructions.

Thank you for any help!

Answer Source

I would not recommend having the config directories as 777. 755 is a much better approach as it lets the owner and group members read and write. You can also try 775 if you want to allow group members to execute. Also, make sure that the web servers user is part of that group. Apache typically uses www-data. I would also recommend moving your config directory to sites/default/sync.

$config_directories = array(
    CONFIG_ACTIVE_DIRECTORY  => 'sites/default/config/active',
    CONFIG_STAGING_DIRECTORY => 'sites/default/config/staging',
    CONFIG_SYNC_DIRECTORY    => 'sites/default/config/sync',

Make sure those directories exists and the web server is part of the group staff.

The other thing I would check is Drupal's status and see what it tells you there.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download