Disable open_basedir in cPanel for error open_basedir restriction in effect

This tutorial explains how to adjust open_basedir attribute in PHP configuration and in case of shared hosting, learn to disable open_basedir via cPanel.

Question: Recently I worked for a client to install Datawrapper application on his Debian Jessie shared hosting server. I did follow all the steps given in the installation manual, but the application failed due to PHP fatal error and the warning hinted “require_once(): open_basedir restriction in effect“.

Below is the snapshot from the web server log.

[18-Feb-2017 15:28:08 UTC] PHP Warning: require_once(): open_basedir restriction in effect. File(/data/web/html/datawrapper/vendor/autoload.php) is not within the allowed path(s): (/data/web/html/datawrapper/www:/data/web/e26373/phpsession:/data/web/phptmp:/tmp:/usr/bin) in /data/web/html/datawrapper/www/index.php on line 14
[18-Feb-2017 15:28:08 UTC] PHP Warning: require_once(/data/web/html/datawrapper/vendor/autoload.php): failed to open stream: Operation not permitted in /data/web/html/datawrapper/www/index.php on line 14
[18-Feb-2017 15:28:08 UTC] PHP Fatal error: require_once(): Failed opening required '../vendor/autoload.php' (include_path='.') in /data/web/html/datawrapper/www/index.php on line 14

How to solve this error?

Solution: By analyzing the error, it shows that a security feature called open_basedir has been enabled. It is primarily used to prevent the web server user from accessing the files stored outside the directory that’s set in open_basedir. So in your case, it looks like open_basedir is set to /data/web/html/datawrapper/www directory and the index.php is trying to access vendor/autoload.php file which is outside the basedir.

Solution 1: Set open_basedir to point to /data/web/html/datawrapper in php.ini

open_basedir  = "/data/web/html/datawrapper"

In case of shared hosting, you may not be able to make changes to php.ini or create one for your account. So follow the solution 2.

How to disable open_basedir via cPanel?

Solution 2: Go to cPanel and look out for PHP Settings. Open the settings of the default PHP version and disable open_basedir feature.

PHP settings in cPanel

Now, try accessing the application and it should work.

Related Content
vps germany
Disclaimer: The content published in this article is the views of the author only. Techglimpse does not gurantee accuracy, completness or validity. If you believe the content on this post violates your copyright, please send us a mail for removal. Read more.