把编译安装的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

相关推荐

  • 文件系统层次标准FHS

    FHS针对目录树架构仅定义出三层目录下应该放置哪些数据,分别是下面三个目录: /(根目录):与开机系统有关; /usr(unix software resource):与软件安装执行有关; /var(variable):与系统运作过程有关。   下面分别对上述三层目录进行详细的阐述。   (1) /(根目录)   根目录是整个系统最重要的一个目录,…

    Linux干货 2016-10-19
  • 网络班27期第五周作业

    N27_网络班 第五周作业 1、 显示当前系统上root、fedora或user1用户的默认shell [root@localhost ~]# grep -E ‘^(root|fedora|user1)’ /etc/passwd | cut -d: -f1,7 2、 找出/etc/rc.d/init.d/function文件中某单词后面跟一组小括号的行,形如…

    Linux干货 2017-08-28
  • 8月5日第七节课作业

    一、当天练习 1、找出ifconfig命令结果中本机的所有IPv4地址 2、查出分区空间使用率的最大百分比值 3、查出用户UID最大值的用户名、UID及shell类型 4、查出/tmp的权限,以数字方式显示 5、统计当前连接本机的每个远程主机IP的连接数,并按从大 到小排序 1、显示/proc/meminfo文件中以大小s开头的行;(要求:使 用两种方式) …

    Linux干货 2016-08-08
  • Linux任务计划命令及应用

    at命令,crontab命令

    2018-03-12
  • Liunx学习第一周之对目录及文件的操作总结

            Liunx学习的第一周已经结束,回顾这一周的学习,已经对Linux的发展历史有了初步的了解,也在老师的指导下成功的在虚拟机上安装了两个Liunx系统:centos6和centos7,然后在这两个Liunx系统的CLI模式下输入一个个命令,让系统执行各种任务,下面是第一周学习的几种命令的总结。 &nbsp…

    2017-07-15