Home > Article > Development Tools > Solving the problem of unresponsiveness when executing any Composer command (open_basedir problem)
The following column composer tutorial will introduce to you the solution to the problem of no response when executing any Composer command (open_basedir problem). I hope it will be helpful to friends in need!
Environment
CentOS 7
Nginx 1.12.0
PHP 7.1.6
Problem
Originally everything was working normally, but because I needed to create a new project, I used Composer to create it, but nothing was displayed, and I successively executed the creation of other projects. There was no response either. After adding the -vvv option, there is no change in the result. Then I try to execute commands such as composer -h, composer self update, etc., but there is no prompt message.
After executing a Composer related command again, I executed echo $? and got the result of 255.
When I tried to install Composer, an error message related to open_basedir appeared. I immediately knew the problem. Before creating a new project this time, I configured the open_basedir option of php.ini. The value is the project directory and /tmp/, the working directory of Composer is the project directory.
After commenting open_basedir and restarting PHP, there was no problem using Composer. But I still want to set open_basedir, here is the answer.
Using Nginx
Whether it is an external request server parsing or a terminal PHP command, the php.ini file will be used, but the execution of Composer is local to the system. In other words, if you set it up from Nginx, executing Composer locally will not be affected.
Nginx added configuration
fastcgi_param PHP_ADMIN_VALUE "open_basedir=项目目录/:/tmp/";
After restarting Nginx and PHP, there is no exception when trying to execute Composer in the terminal. There are two points to note when configuring open_basedir in Nginx configuration.
If your program is a framework, it is not recommended to write $document_root/, because that is the root value, and this value is the directory of the entrance to the framework, and an error will occur during operation. If you understand, you can also write $document_root/, but don’t forget to add the directory where the entire website is located
Remember to add "/" at the end of the directory, for example, write "/tmp/" instead of "/tmp ", if you write "/tmp", then "/tmp1" is also within the allowed range
I just want to use php.ini
The thing is obvious, Composer command The directories required for execution are not only the project directory (which is also the working directory where I execute the Composer command) and the tmp directory. I searched for relevant information but found no results. Finally, I sorted out my ideas and added the original value of open_basedir in php.ini. After locating the directory where the Composer command is located and the Composer file directory, restart PHP and Composer will be normal.
The above is the detailed content of Solving the problem of unresponsiveness when executing any Composer command (open_basedir problem). For more information, please follow other related articles on the PHP Chinese website!