How to set for specific directory open_basedir
You can set the open_basedir configuration option in the PHP configuration file (php.ini) to specify a specific directory for the open_basedir setting.
You can set the open_basedir configuration option in the PHP configuration file (php.ini) to specify a specific directory for the open_basedir setting. The directive can be set to a single directory or a list of directories separated by a colon (:).
Example:
Example of setting the open_basedir configuration option in the PHP configuration file (php.ini)
open_basedir = "/var/www/html/myapp:/tmp"
<div class="alert alert-info flex not-prose">![]()
<span class="hidden md:block">Watch a video course</span>Learn object oriented PHP</div>
This will set open_basedir to allow access to only the /var/www/html/myapp and /tmp directories.
You can also set open_basedir on a per-directory basis using an .htaccess file in the directory you want to restrict.
Example of setting open_basedir on a per-directory basis using an .htaccess file in PHP
php_admin_value open_basedir "/var/www/html/myapp"Note that php_admin_value in .htaccess only works with the mod_php Apache module. For modern PHP-FPM setups, you must configure open_basedir in the PHP-FPM pool configuration file (e.g., www.conf).