PHP-FPM Self-starter script

Source: Internet
Author: User
Think manual operation php-fpm Quite troublesome, oneself try to write a script to realize the boot, realize their own desired effect.


1. Scripts

#!/bin/bash#chkconfig:2345 #description: Auto start php-fpmdaemon=/usr/local/php/sbin/php-fpmcase $ In ' start ') Proc_id= ' echo $ (netstat-lnutp | grep php-fpm) | Gawk ' {print $7} ' | Gawk ' begin{fs= '/'}{print} ' >/dev/null 2>&1 if [!     "$proc _id" = ""] then echo "PHP-FPM is running!"         else if [' $daemon '] then echoes "PHP-FPM not Stard."         else echo "php-fpm stard."     fi fi;; ' Stop ') proc_id= ' echo $ (netstat-lnutp | grep php-fpm) | Gawk ' {print $7} ' | Gawk ' begin{fs= '/'}{print} ' >/dev/null 2>&1 if [!     "$proc _id" = "] then kill-term $proc _id echo" php-fpm stopd. "     else echo "php-fpm not running,do not anything."     fi;; ' Restart ') proc_id= ' echo $ (netstat-lnutp | grep php-fpm) | Gawk ' {print $7} ' | Gawk ' begin{fs= '/'}{print} ' #>/dev/null 2>&1 if [! "$proc _id" = ""] then Kill-tERM $proc _id echo "php-fpm stopd."     else echo "php-fpm not running,do not anything." Fi sleep 5 proc_id= ' echo $ (netstat-lnutp | grep php-fpm) | Gawk ' {print $7} ' |         Gawk ' begin{fs= '/'}{print $} ' #>/dev/null 2>&1 if ["$proc _id" = ""] then If [' $daemon ']         Then echo "PHP-FPM not stard."         else echo "php-fpm stard."     fi fi;; *) echo "Usage: $ start|stop|restart";; Esac


2. Copy script to startup directory

CP PHP-FPM.SH/ETC/INIT.D/PHP-FPM


3. Add self-starter

Chkconfig PHP-FPM on


4. Viewing effects

Chkconfig--list


[Root@localhost fonts]# chkconfig--list


Note: This output shows only the SysV service and does not contain the native SYSTEMD service. SysV configuration data may be overwritten by native SYSTEMD configuration.

If you would like to list the SYSTEMD service, please do ' systemctl list-unit-files '.

To view services enabled for a specific target, perform

' Systemctl list-dependencies [target] '.


httpd 0: Off 1: Off 2: Off 3: Open 4: Off 5: Open 6: Off

Mysqld 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off

Netconsole 0: Off 1: Off 2: Off 3: Off 4: off 5: off 6: Off

Network 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off

Nginx 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off

PHP-FPM 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off

Zabbix_agentd 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off

Zabbix_server 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off

  • 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.