Roots Discourse

Open_basedir restriction in effect error

Hi, i’ve made a fresh local development setup with bedrock-ansible + bedrock + roots theme. Now when i am activating the roots theme, i am getting this errors:

Warning: is_writable(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/srv/www/:/tmp) in /srv/www/test.dev/current/web/wp/wp-admin/includes/misc.php on line 170

Warning: Cannot modify header information - headers already sent by (output started at /srv/www/test.dev/current/web/wp/wp-admin/includes/misc.php:170) in /srv/www/test.dev/current/web/wp/wp-includes/pluggable.php on line 1178

What is causing these error messages?

open_basedir is a PHP setting for better security. It means that PHP can only open files in /srv/www/ and /tmp (which is a good thing).

For some reason it looks like it’s trying to open a file in just /. That error is actually from this line:

Not sure what’s going on with your install as .htaccess doesn’t apply using Nginx. I’ve personally never seen that error or heard of anyone having it before.

I had a similar error once, related to the PODS plugin. As mentioned here, I added session.save_path = /tmp to my php.ini (e.g., to roles/php/templates/php.ini.j2 in bedrock-ansible).

If you choose to adjust session.save_path and you are using bedrock-ansible, note that bedrock-ansible already has a session.save_path setting in roles/wordpress-sites/templates/php-fpm.conf.j2. However, it is conditional, and would only conflict if you’ve set memcached_sessions: true (default is false) in roles/wordpress-sites/defaults/main.yml.

2 Likes

Thanks for the explanations. I couldn’t find the problem so after i removed everything including vagrant box and made setup again, problem resolved. But i don’t know what was the cause.

I briefly had the same error after getting this update done :

composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 4 updates, 0 removals
  - Updating johnpbloch/wordpress-core (4.7.3 => 4.7.4): Loading from cache
  - Updating johnpbloch/wordpress (4.7.3 => 4.7.4): Loading from cache
  - Updating wpackagist-plugin/woocommerce (3.0.4 => 3.0.5): Downloading (100%)   - Updating squizlabs/php_codesniffer (2.8.1 => 2.9.0): Loading from cache
Writing lock file
Generating autoload files

The error I got was the same as mentioned:

is_writable(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/srv/www/:/tmp) in /../wp-admin/includes/misc.php on line 209

When I reloaded the site the error disappeared again. When I checked the error logs using
tail /srv/www/sub.domain.com/logs/error.log I had zero data in the logs. Latest errors were from two months ago. Odd, really, but that is all I can say about it now. Perhaps a glitch?

This wordpress-sites directory must have changed since this posting in Jan 15. I can only find the php-fpm.conf.j2 file in roles/wordpress-setup/templates now since there is no wordpress-sites directory.

I just started using the Trellis/Bedrock packages, but I am also getting this error that I can’t seem to find any current instructions on how to correct this error.

Warning: is_writable() [function.is-writable]:
open_basedir restriction in effect.
File(/) is not within the allowed path(s):

Also, my roles/php/templates/php.ini.js looks like this:
session.save_path = {{ php_session_save_path }}

Could I just add the extra / directory at the end preceeding it with a colon?
e.x. session.save_path = {{ php_session_save_path }}:/tmp:/

If you need to temporarily remove basedir restrictions on the fly, here’s a where you can manually make the open_basedir = none change. Keep in mind this is not the best practice but I’m sharing it to help you get out of a temporary jam.

    php -v
    cd /etc/php/7.3/fpm/pool.d
    nano wordpress.conf
# change value to = none
    php_admin_value[open_basedir] = none
# quit + save
    systemctl restart php7.3-fpm