• 将php配置为服务


    将以下代码保存为php-fpm,修改路径为自己的路径(有php.ini的)

    #!/bin/bash
    #
    # Startup script for the PHP-FPM server.
    #
    # chkconfig: 345 85 15
    # description: PHP is an HTML-embedded scripting language
    # processname: php-fpm
    # config: /usr/local/php/etc/php.ini
    
    # Source function library.
    . /etc/rc.d/init.d/functions
    
    PHP_PATH=/usr/local
    DESC="php-fpm daemon"
    NAME=php-fpm
    # php-fpm路径
    DAEMON=$PHP_PATH/php/sbin/$NAME
    # 配置文件路径
    CONFIGFILE=$PHP_PATH/php/etc/php-fpm.conf
    # PHP.ini文件路径
    INI_CONFIGFILE=$PHP_PATH/php/etc/php.ini
    # PID文件路径(在php-fpm.conf设置)
    PIDFILE=$PHP_PATH/php/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME
    
    # Gracefully exit if the package has been removed.
    test -x $DAEMON || exit 0
    
    rh_start() {
      $DAEMON -y $CONFIGFILE -c $INI_CONFIGFILE || echo -n " already running"
    }
    
    rh_stop() {
      kill -QUIT `cat $PIDFILE` || echo -n " not running"
    }
    
    rh_reload() {
      kill -HUP `cat $PIDFILE` || echo -n " can't reload"
    }
    
    case "$1" in
      start)
            echo -n "Starting $DESC: $NAME"
            rh_start
            echo "."
            ;;
      stop)
            echo -n "Stopping $DESC: $NAME"
            rh_stop
            echo "."
            ;;
      reload)
            echo -n "Reloading $DESC configuration..."
            rh_reload
            echo "reloaded."
      ;;
      restart)
            echo -n "Restarting $DESC: $NAME"
            rh_stop
            sleep 1
            rh_start
            echo "."
            ;;
      *)
             echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
             exit 3
            ;;
    esac
    exit 0
    

     

    无php.ini的

    #!/bin/bash
    #
    # Startup script for the PHP-FPM server.
    #
    # chkconfig: 345 85 15
    # description: PHP is an HTML-embedded scripting language
    # processname: php-fpm
    # config: /usr/local/php/etc/php.ini
     
    # Source function library.
    . /etc/rc.d/init.d/functions
     
    PHP_PATH=/usr/local
    DESC="php-fpm daemon"
    NAME=php-fpm
    # php-fpm路径
    DAEMON=$PHP_PATH/php/sbin/$NAME
    # 配置文件路径
    CONFIGFILE=$PHP_PATH/php/etc/php-fpm.conf
    # PID文件路径(在php-fpm.conf设置)
    PIDFILE=$PHP_PATH/php/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME
     
    # Gracefully exit if the package has been removed.
    test -x $DAEMON || exit 0
     
    rh_start() {
      $DAEMON -y $CONFIGFILE || echo -n " already running"
    }
     
    rh_stop() {
      kill -QUIT `cat $PIDFILE` || echo -n " not running"
    }
     
    rh_reload() {
      kill -HUP `cat $PIDFILE` || echo -n " can't reload"
    }
     
    case "$1" in
      start)
            echo -n "Starting $DESC: $NAME"
            rh_start
            echo "."
            ;;
      stop)
            echo -n "Stopping $DESC: $NAME"
            rh_stop
            echo "."
            ;;
      reload)
            echo -n "Reloading $DESC configuration..."
            rh_reload
            echo "reloaded."
      ;;
      restart)
            echo -n "Restarting $DESC: $NAME"
            rh_stop
            sleep 1
            rh_start
            echo "."
            ;;
      *)
             echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
             exit 3
            ;;
    esac
    exit 0
    

      

    然后运行

    cp ./php-fpm /etc/init.d/php-fpm
    chmod +x /etc/init.d/php-fpm
    
    chkconfig --level 35 php-fpm on
    service php-fpm restart
    

      

  • 相关阅读:
    delphi SysErrorMessage 函数和系统错误信息表 good
    Delphi中ShellExecute使用详解(详细解释10种显示状态)
    几个获取Windows系统信息的Delphi程序
    判断操作系统多久没有任何操作
    MVC4+WebApi+Redis Session共享练习(下)
    MVC4+WebApi+Redis Session共享练习(上)
    EntityFramework使用总结(与MVC4.0实现CURD操作)
    MVC3.0+knockout.js+Ajax 实现简单的增删改查
    基于Redis缓存的Session共享(附源码)
    Redis缓存服务搭建及实现数据读写
  • 原文地址:https://www.cnblogs.com/icyy/p/4672184.html
Copyright © 2020-2023  润新知