Home > Operation and Maintenance > Linux Operation and Maintenance > Manage the compiled and installed httpd using service and chkconfig

Manage the compiled and installed httpd using service and chkconfig

巴扎黑
Release: 2017-07-23 10:48:45
Original
1611 people have browsed it

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

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
Copy after login

可以看到已经添加成功

4 通过service 命令启动服务

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

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

98 #ServerName www.example.com:80

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

The above is the detailed content of Manage the compiled and installed httpd using service and chkconfig. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template