zoukankan      html  css  js  c++  java
  • 将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
    

      

  • 相关阅读:
    Firefox浏览器怎么安装adobe flash player插件
    uploadify在火狐下上传不了的解决方案,java版(Spring+SpringMVC+MyBatis)详细解决方案...
    thinkphp模版调用函数方法
    Thinkphp模板中函数的使用
    60.0.1(64位)windows版 uploadify使用有问题
    一起谈.NET技术,异步调用与多线程的区别 狼人:
    一起谈.NET技术,Silverlight中使用递归构造关系图 狼人:
    一起谈.NET技术,ASP.NET Routing对请求的处理方式 狼人:
    一起谈.NET技术,闲话“多线程” 狼人:
    一起谈.NET技术,利用.NET Framework4.0的源代码调试你的应用程序 狼人:
  • 原文地址:https://www.cnblogs.com/icyy/p/4672184.html
Copyright © 2011-2022 走看看