把编译安装的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基础知识之软件包管理(二)

    (1)CentOS7 yum dnf  yum repository: yum repo 存储了众多rpm包,以及包的相关的元数据文件(放置于特定目录下,repodata) 文件服务器: ftp:// http:// nfs:// file:/// (2)yum客户端: 配置文件: /etc/yum…

    Linux干货 2016-08-24
  • httpd功能配置之路径别名

       httpd的路径别名功能可以使用资源的访问不再依赖于站点的根目录,可以指定任意目录来设置资源的访问路径。    默认站点的根目录是/var/www/html,如下图所示。    下面来使用路径的别名来访问资源:    1、打开httpd服务的配置文件  &nbsp…

    Linux干货 2016-03-11
  • linux学习第二天知识点-linux入门及使用帮助

    一 基础命令 1. #ifconfig     显示或配置网卡的命令,英文全称是network interfaces configuring。     配置网卡的IP地址语法例:ifconfig eth0 192.168.0.1 netmask 255.255.255.0 2.&…

    Linux干货 2016-07-26
  • Nginx 编译安装

    Nginx (“engine x”) 是一个高性能的 HTTP 和 反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服 1、Apache服务器和nginx的优缺点: Apache具有很优秀的性能,而且通过模块可以提供各种丰富的功能。 1)首先Apache对客户端的响应是支持并发的 ,运行httpd这个daemon进程之后,它会同时产生多个子进程/…

    Linux干货 2017-02-06
  • vim必掌握用法

    vim最入门用法大全

    Linux干货 2017-12-03
  • 马哥教育网络班22期+第九周课程练习

    1. 写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; #!/bin/bash#declare -a loginuserdeclare -i sum_login=0declare -i sum_nologin=0list=($(cat /et…

    Linux干货 2017-01-03