Php-fpm often appears 502 solution _ PHP Tutorial

Source: Internet
Author: User
Php-fpm often provides 502 solutions. Php-fpm often appears 502 solution more Please support: www.Bkjia.com nginx often 502 recently, the best solution to 502 is to restart php-fpm. Manual restart is still a hassle. php-fpm often offers 502 solutions.

For more information, see www.Bkjia.com.


Nginx is often 502 recently. The best solution to 502 is to restart php-fpm.
Manual restart is still troublesome. The best thing is to throw it to the shell.

Vim restart-php-fpm.sh.

#!/bin/shSERVICE='php-fpm'#if ps ax | grep -v grep | grep $SERVICE > /dev/nullif netstat -anp | grep 9000 > /dev/nullthen    echo $SERVICE service running, everything is fineelse    echo $SERVICE is not running    service php-fpm startfi
The local virtual machine tested it. it was feasible to throw it to the server. it was found that no php-fpm process was found at 502, but php-fpm was dead.
Therefore, another solution is adopted:

Vim restart-php-fpm.sh.

#! /Bin/bashMY_URL = http://www.webyang.netRESULT = 'curl-I $ MY_URL | grep HTTP/1.1 502 \ 'if [-n $ RESULT]; then # if 502, the content here will be executed, add or modify killall-9 php-cgiservice php-fpm restartfi
In this case, you can manually add it to the crontab if you need it automatically.
Chmod 755 restart-php-fpm.sh
Run crontab-e
Set the restart-php-fpm.sh to run automatically every minute (time can be adjusted as needed)
*/1 ***/home/restart-php-fpm.sh
Check whether the setting is successful or not.
Crontab-l

Or you can write a shell endless loop and execute it every other time.

For more information, see www.Bkjia.com. nginx is often 502 recently. The best solution to this problem is to restart php-fpm. Manual restart is still troublesome ,...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.