111 发表于 2018-11-17 12:27:24

将apache添加为开机启动有两个方法

  将apache添加为开机启动有两个方法:
  1、在/etc/rc.d/rc.local内加入启动命令 /usr/local/apache2/bin/apachectlstart
  2、将http添加为系统服务
  cp /usr/local/apache2/bin/apachectl/etc/rc.d/init.d/httpd
  chmod +x/etc/rc.d/init.d/httpd
  # chkconfig --add httpd
  # chkconfig --list|grep httpd
  httpd         0:关闭 1:关闭2:关闭 3:关闭4:关闭5:关闭6:关闭
  # chkconfig --level 345 httpd on
  # chkconfig --list|grep httpd
  httpd         0:关闭1:关闭 2:关闭 3:启用 4:启用 5:启用6:关闭
  如果出现# chkconfig --add httpd
  httpd 服务不支持 chkconfig
  解决过程如下:
  编辑/etc/rc.d/init.d/httpd
  #!/bin/bash
  #chkconfig:345 61 61   //此行的345参数表示,在哪些运行级别启动,启动序号(S61);关闭序号(K61)
  #description:Apache httpd   //此行必写,描述服务.
  添加红色部分就可以拉!
  再# chkconfig --add httpd
  # chkconfig --list|grep httpd
  httpd         0:关闭 1:关闭2:关闭 3:关闭4:关闭5:关闭6:关闭
  # chkconfig --level 345 httpd on
  # chkconfig --list|grep httpd
  httpd         0:关闭1:关闭 2:关闭 3:启用 4:启用 5:启用6:关闭

页: [1]
查看完整版本: 将apache添加为开机启动有两个方法