把编译安装的httpd 实现服务脚本,通过service和chkconfig 进行管理

把编译安装的httpd 实现服务脚本,通过service和chkconfig 进行管理

1 编译安装httpd

把httpd编译安装在/app/httpd/目录下。

2 在/etc/rc.d/init.d/目录下新建一个文件httpd

这个文件的目的在于让service 命令可以管理编译安装的httpd服务。

文件内容如下:

[root@CentOS68 ~]# cat /etc/rc.d/init.d/httpd
#!/bin/bash
#
# httpd        Start up the httpd server daemon
#
# chkconfig: 2345 99 01
# description: httpd is a protocol for web server.
# This service starts up the httpd server daemon.
#
# processname: httpd
case $1 in
start)
/app/httpd/bin/apachectl start ;;
stop)
/app/httpd/bin/apachectl stop ;;
status)
/app/httpd/bin/apachectl status ;;
*)
echo err
esac

3 添加为开机启动

[root@CentOS68 /app/httpd/bin]# chkconfig --add httpd
[root@CentOS68 /app/httpd/bin]# chkconfig --list |grep httpd
httpd     0:off    1:off    2:on    3:on    4:on    5:on    6:off
[root@CentOS68 /app/httpd/bin]#

可以看到已经添加成功

4 通过service 命令启动服务

[root@CentOS68 ~]# service httpd start
httpd: Could not reliably determine the server's fully qualified domain name, using CentOS68.localhost for ServerName

可以看到会报错,但是服务已经启动成功了,修改/app/httpd/conf/httpd.conf这个文件,把98行前面的#去掉即可

98 #ServerName www.example.com:80

现在可以通过service命令管理手动安装的httpd 服务了

原创文章,作者:linux is not unix,如若转载,请注明出处:http://www.178linux.com/75696

(2)
linux is not unixlinux is not unix
上一篇 2017-05-15
下一篇 2017-05-15

相关推荐

  • linux终端类型

    终端分为:             ∟  物理终端         定义:可将显示器,键盘,鼠标直接接入主机接口的终端;     &nbsp…

    Linux干货 2016-10-18
  • 逻辑卷管理—LVM

    逻辑卷管理—LVM   LVM:Logical  Volume  Manager        使用软件方式来组织一个或多个底层硬件设备为一个抽象的逻辑设备。 1、查看分区情况: 2、创建分区:(更改分区类型为8e:Linux LVM) 3、创建分区成功: 5、创建物理…

    Linux干货 2016-09-01
  • linux进程管理相关工具

    linux进程管理相关工具: pstree ,ps ,pidof ,pgrep ,top ,htop ,glances ,pmap ,vmstat ,kill ,killall ,job ,bg ,fg ,nohup ,nice ,renice ,pkill…… 1、pstree:查看进程树 2、ps:显示执行命令时间的进程状态信息 /proc 目录下存放内…

    Linux干货 2016-09-11
  • 少走冤枉路!带你走过SNMP的那些坑

    SNMP(Simple Network Management Protocol)即简单网络管理协议,是在网络与系统监控领域中,最常使用的一种数据采集技术。尽管这个协议非常简单,但在大规模IT环境监测中,还是经常会碰到各种坑,因此优云开源了一套友好的SNMPAPI,并通过本文简单介绍这套API中的一些特点,希望帮助各位运维同仁提前规避一些问题。 特点[0].&…

    2016-06-22
  • redis-cli的一些有趣也很有用的功能

    redis-cli我们最常用的三个参数就是-h、-p、-a选项,分配用来指定连接的redis-server的host、port和登录密码。通过redis-cli –help发现,redis-cli还提供了其他很多的参数和功能。 1)-x-x选项从标准输入(stdin)读取最后一个参数。 比如从管道中读取输入: echo -en &quot…

    Linux干货 2016-04-13
  • find命令

          find:实时查找工具,根据我们指定的内容或者条件在系统上进行实时查找,比locate在实际场景中用的多得多的多      具体用法:find   查找路径      查找条件         &n…

    Linux干货 2017-04-10