What should I do if the PHP open_basedir error occurs in the VestaCP panel?

solveVestaCPphp open_basedir error problem with panel

What is PHP open_basedir?

  • The PHP open_basedir protection tweak is a safe-mode security measure that prevents users from using PHP to open files or scripts located outside of their home directory, unless that folder has been explicitly excluded.
  • Enabling the PHP open_basedir setting will ensure that all file operations are restricted to files under a certain directory, preventing php scripts from a specific user from accessing files in unauthorized user accounts.
  • When the script tries to open the file with e.g. fopen() or gzopen(), the location of the file is checked.

There are more related tutorials on VestaCP panels here ▼

When a file exceeds the specified or allowed directory tree, PHP will refuse to open it, an error similar to the following may occur:

PHP Warning: require(): open_basedir restriction in effect. File(/home/admin/web/project/www/app/autoload.php) is not within the allowed path(s): (/home/admin/web/project/public_shtml:/home/admin/tmp) in /home/admin/web/project/www/web/app.php on line 6

PHP Warning: require(/home/admin/web/project/www/app/autoload.php): failed to open stream: Operation not permitted in /home/admin/web/project/www/web/app.php on line 6

PHP Fatal error: require(): Failed opening required '/home/admin/web/project/www/web/../app/autoload.php' (include_path='.:/usr/share/php') in /home/admin/web/project/www/web/app.php on line 6

Solution

Step 1:Enter the corresponding domain name "WEB service".

Step 2:Modify "Web Template HTTPD"

  • Please change "Web Template HTTPD" from "default" to "phpcgi" ▼

VestaCP panel changed "Web Template HTTPD" from "default" to "phpfcgid" Sheet 4

Step 3:Restart the Apache service with the following command ▼

service httpd restart

这 是LinuxThe common problems of the system, as long as you follow the above methods, no need to modify the code, you can quickly solve them in just 3 steps, very simple ^_^

Attention points

  • Never choose "phpfcgid", because it is easy to consume too much memory and cause frequent 500 error problems.

If you prefer to use the "phpfcgid" template,Chen WeiliangIt is recommended that you optimize the settings before using it ▼

Comment

Your email address will not be published. Required fields * Callout

Scroll to Top