Bobcares

WordPress Warning: open_basedir restriction in effect

by | Jun 22, 2021

The WordPress Warning: open_basedir restriction in effect is a security restriction to prevent a user on a webserver to access files and folders that belong to another user.

As part of our Server Management Services, we assist our customers with several WordPress queries.

Today, let us see how we can fix this warning.

 

WordPress Warning: open_basedir restriction in effect

Generally, we come across these errors while accessing the site:

open_basedir restriction in effect. File(/tmp) is not within the allowed path(s).
Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/home/some/path/here/) is not within the allowed path(s).
Warning: is_writable() [function.is-writable]: open_basedir restriction in effect.
File(/) is not within the allowed path(s).

Basically, the intention of this warning is to restrict another user from using our webserver.

For example, suppose, a function, say, mkdir in a WordPress theme or plugin tries to access a file or folder outside its home directory. It will not be able to access it and in effect, the error.

The fix to this error is multiple.

We can either disable the restriction completely or selectively allow access to some files and folders outside the home directory for some users.

Another option is to debug the code of the WordPress theme and plugin so that it doesn’t need to access files and folders outside its root folder.

 

Fix open_basedir restriction Error in WordPress

Moving ahead, let us see how our Support Techs fix this error.

1. Initially, we open the web-config file via FTP and add:

DEFINE(‘WP_HOME’,’HTTP://DOMAIN.COM’);
DEFINE(‘WP_SITEURL’,’HTTP://DOMAIN.COM’);

Here, we replace domain.com with our own domain name.

2. We then bowse the server files either via FTP or Panel

Then in the wp-content folder, we create a new folder with a name.

In addition, we ensure to give the writing rights to the folder.

After that, we go to the WordPress admin panel > Settings > Media.

Here, we change the path of uploading files with the name of the new directory we created.

This should help to work. However, if not, we suggest another step:

3. We create a new .htaccess file and overwrite the new file with the old file.

This time, it should definitely work.

 

Disable the PHP open_basedir restriction

On the other hand, if we don’t have either Cpanel WHM or Plesk on the VPS or dedicated hosting, we edit the Apache configuration file to disable the restriction.

To do this, we open httpd.conf file, and find the line:

php_admin_value open_basedir some_value_here

Then we replace it with:

php_admin_value open_basedir none

We ensure to make this change under the virtual host for the domain user account on which we want to disable the open_basedir protection.

We can allow the PHP scripts in any user account to access specific directories outside their home directory, without disabling the restriction completely.

To do so, to the httpd.conf file we add the below code:

php_admin_value open_basedir “/home/user_account/:/usr/local/lib/php:/tmp:/new_directory”

We can add directories by separating them with a colon (:) on Unix and Linux server and with a semicolon (;) on Windows servers.

Restart the Apache server after making any change to the httpd.conf file.

A rule of /dir/incl will also match /dir/includes. To make sure it matches the particular directory, we add a trailing slash, like /dir/incl/.

[Stuck with the fix? We are here for you]

 

Conclusion

In short, we saw how our Support Techs fix the WordPress warning for our customers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF