Home > Article > Backend Development > 502 error when running php file - non-timeout issue
The first thing to make sure is that the static files of the website such as html, txt, etc. can be accessed normally. It means there is no problem with nginx
Then a 502 error occurs when accessing the php file. It is not a response problem, but a 502 error occurs directly. Then this experience may help you
The probability of this kind of problem is relatively low. What I wrote is just to provide beginners with a solution to the problem. The reason is simple, because php is not started.
This example assumes that the cloud server can be accessed. If this problem occurs in the purchased space, you can contact the space service provider
First, determine whether php is running normally and execute the command (recommended learning: PHP video tutorial )
php -v
As shown below, the prompt command is not found, indicating that php is not running.
Start PHP. The directory below is not a general directory. I am using Alibaba Cloud Server. My PHP directory is in the directory below. If you installed php using other methods, you can look for the php directory.
To be honest, the startup file is /sbin/php-fpm under the php root directory
/alidata/server/php-5.4.23/sbin/php-fpm
As shown below, The reason why my 502 appears is because php has not been started, and the reason why it cannot be started is because the configuration file cannot be found.
The reason is that the previous operation and maintenance ran away without configuring the environment. So the project cannot run.
My solution here is to change the name of the directory /php-5.4.23/ directly to /php/ and it will be all done
To summarize, if you have no problem accessing static files, but all PHP file access directly prompts a 502 error, then you can consider whether it is because the PHP function or the process has not started.
Check the php version by command php -v to check whether php starts normally.
If it is indeed a 502 error caused by php not being started.
Then find your php root directory and find the corresponding configuration file
/alidata/server/php-5.4.23/sbin/php-fpm
Then start it, and solve the corresponding problems if you encounter other problems
The above is the detailed content of 502 error when running php file - non-timeout issue. For more information, please follow other related articles on the PHP Chinese website!