CityHost.UA
Help and support

Hestia CP: Disable open_basedir function

If the site has problems loading pages related to the open_basedir function, as evidenced by the error open_basedir restriction in effect (can occur both on the site pages and only in [error logs] on the server), you can disable this function.

In short, the open_basedir function restricts access from the site's php scripts to other scripts and directories located outside the site. Its main purpose is to isolate sites from each other, so that each site "sees" only the files/directories of its root directory, and does not interfere with the work of other sites/directories.

This instruction is relevant only for the Hestia control panel, it may not be relevant for other panels or types of servers. Before starting work, make sure that you have taken a [snapshot of the server] . All operations are performed at the peril and risk of the server owner.

So, you need to comment out the line related to this function in the template config file. Template files are located at /usr/local/hestia/data/templates/web/php-fpm/ and have names similar to PHP versions for which open_basedir should be disabled. For example, the template for PHP 7.4 is named PHP-7_4.tpl

In this file there is a line php_admin_value[open_basedir] = ... our goal is to comment it by adding a semicolon symbol to the beginning of the line so that it turns out like this ; php_admin_value[open_basedir] = ...

To do this, you can use any file editor like nano or vim, or run the following command, it will find the line you want and comment it out. Pay attention to the file name in the command, if you have a different version of PHP, do not forget to change the file name because the following example is for PHP 7.4.

sed -i 's/php_admin_value\[open_basedir\]/;php_admin_value\[open_basedir\]/g' /usr/local/hestia/data/templates/web/php-fpm/ PHP-7_4.tpl

All that remains is to save the changes from the template to the main site config and restart the PHP 7.4 service, all this can be done either manually through the control panel and the panel files, or you can execute just one command. Please note that the command has 3 variables, the user name (admin) of the control panel where the site is located, the domain of the site (example.pp.ua), and the name of the template (PHP-7_4) that we edited above. As with the case above, change this data to your own before running the command.

v-change-web-domain-backend-tpl admin example.pp.ua PHP-7_4

done

Now you can check if the function is disabled using [phpinfo test php script] .

Here's what it looks like with open_basedir enabled (first screenshot) and disabled (second screenshot)