The main content of this article is about the configuration of open_basedir under PHP. It has a certain reference value. Now I share it with everyone. Friends in need can refer to it
After downloading the YII2.0 framework and After successfully configuring nginx, I found that it was still inaccessible. I checked the error log and found that the error message included require(): open_basedir restriction in effect. So I searched online and found that the PHP configuration item open_basedir restricted the path accessed by require().
open_basedir limits the files that php can open to the specified directory tree, including the file itself. When a program opens a file using, for example, fopen() or file_get_contents(), the location of the file is checked. When the file is outside the specified directory tree, the program will refuse to open it.
In Linux systems, open_basedir is mainly configured in the php.ini and fastcgi.conf files. The configuration in php.ini is as follows: open_basedir="specified directory"; the configuration in fastcgi.conf is as follows: fastcgi_param PHP_VALUE "open_basedir =Specify directory";
Under Windows, it is mainly configured in the http.conf file of php.ini and apache. The configuration in http.conf is as follows: php_admin_value open_basedir "Specify directory".
The limit specified with open_basedir is actually a prefix, not a directory name. In other words, open_basedir=/home/fdipzone will also allow access to /home/fdipzone_abc. If you want to limit access to a directory, please use a slash to end the path name, for example: open_basedir=”/home/fdipzone/”. If you want to set up multiple directories, window uses; to separate directories, and Linux uses: to separate directories.
Using open_basedir can limit the directories and files that the program can operate and improve system security. However, it will affect I/O performance and cause system execution to slow down. Therefore, it is necessary to balance security and performance according to specific needs.
The above is the detailed content of Configuration of open_basedir under php. For more information, please follow other related articles on the PHP Chinese website!