Article directory
Solving the PHP open_basedir error in the VestaCP 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: Access the corresponding domain name "WEB Service".
Step 2: Modify "Web Template HTTPD"
- Please change "Web Template HTTPD" from "default" to "phpcgi" ▼

Step 3: Restart the Apache service using the following command ▼
service httpd restart
This is a common problem in Linux systems. Just follow the steps above; no code modification is required, and it can be quickly resolved in just 3 steps. It's very simple! ^_^
Attention points
- Never choose "phpfcgid", because it is easy to consume too much memory and cause frequent 500 error problems.
If you insist on using the "phpfcgid" template, Chen Weiliang suggests optimizing its settings before use. ▼
Hopefully, the article "How to fix the PHP open_basedir error in the VestaCP panel?" shared on Chen Weiliang's blog ( https://www.chenweiliang.com/ ) will be helpful to you.
Feel free to share this article's link: https://www.chenweiliang.com/cwl-734.html


