PHP-FPM often appears 502 solutions

Source: Internet
Author: User
Please support: http://www.webyang.net/Html/web/article_134.html


Recently nginx often 502, solve 502 the best way is to restart PHP-FPM.
Manual to restart or more troublesome things, the best is to throw into 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 fine\" else    echo \ "$SERVICE was not Runn ing\ "    Service php-fpm Startfi
Local virtual machine test, feasible, throw to the server, the results found that 502 did not php-fpm no process, but PHP-FPM zombie.
So I went. Another option:

Vim restart-php-fpm.sh

#!/bin/bashmy_url=\ "http://www.webyang.net\" result=\ ' curl-i $MY _url | grep \ "http/1.1 502\" \ "if [-n \" $RESULT \ "]; then# If 502 will execute the content here, add or change killall-9 php-cgiservice php-fpm Restartfi
This way, or manual, if you need to automatically add yourself to the crontab.
chmod 755 restart-php-fpm.sh
Run CRONTAB-E
Set restart-php-fpm.sh to be executed automatically every minute (time can be adjusted according to your own requirements)
*/1 * * * */home/restart-php-fpm.sh
To see if a setting succeeds or fails
Crontab-l

or write a shell dead loop, and execute it every other time.

  • Related Article

    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.