开发者社区> 问答> 正文

如何实现编译安装的 Apache 服务,随系统自动启动

如何实现编译安装的 Apache 服务,随系统自动启动

展开
收起
开发者说 2019-07-12 09:31:03 521 0
1 条回答
写回答
取消 提交回答
  • 问题描述

    如何实现编译安装的 Apache 服务,随系统自动启动

    解决方案

    假设 Apache 安装的路径为 /usr/local/apache/

    注意:实际安装路径以您真实的安装路径为准

    1、首选需要将 /usr/local/apache/bin/apachectl 文件拷贝到 /etc/rc.d/init.d 目录中并更名为 httpd,具体操作命令为:

    cp /usr/local/apache/bin/apachectl  /etc/rc.d/init.d/httpd

    并且还需要在/etc/rc.d/rc5.d/加入链接,具体操作命令为:

    ln -s /etc/rc.d/init.d/httpd  /etc/rc.d/rc5.d/S85httpd 

    2、这时可以运行 chkconfig --list | grep httpd,查看服务列表中是否存在 httpd 这个服务;如果没有,可以通过 chkconfig --add httpd 来添加。如果在添加时出现提示:service httpd does not support chkconfig

    需要编辑 /etc/rc.d/init.d/httpd,在文件空白行添加以下信息,可以使用vi进行编辑操作

    #chkconfig: 345 85 15
    #description: Activates/Deactivates Apache Web Server

    其中3个数字参数意义分别为:

    哪些Linux级别需要启动httpd(3,4,5);启动序号(85);关闭序号(15)

    保存后执行:chkconfig --add httpd 成功添加

    3、运行 chkconfig --list | grep httpd 查看启动级别3,4,5 已经处于on的状态,说明已经设置成功。

    2019-07-22 11:30:43
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Apache Flink技术进阶 立即下载
Apache Spark: Cloud and On-Prem 立即下载
Hybrid Cloud and Apache Spark 立即下载

相关镜像