linux编译安装apache开机启动,编译安装apache添加开机自启动

[[email protected] /]# cat /etc/redhat-release

CentOS Linux release 7.4.1708 (Core)

[[email protected] /]# uname -r

3.10.0-693.el7.x86_64

2、源码编译安装apache服务后,设置开机自启动报错信息

[[email protected] ~]# systemctl enable httpd

httpd.service is not a native service, redirecting to /sbin/chkconfig.

Executing /sbin/chkconfig httpd on

[[email protected] ~]# chkconfig --add httpd

service httpd does not support chkconfig

3、解决方法或思路

1)编写apache启动脚本

[[email protected] ~]# cd /etc/init.d/

[[email protected] init.d]# touch httpd

[[email protected] ~]# vim httpd

#!/bin/bash

#chkconfig:345 85 15

#description:Start and stop the Apache HTTP Server

function httpd_start(){

/usr/local/apache/bin/apachectl start

}

function httpd_stop(){

/usr/local/apache/bin/apachectl stop

}

case $1 in

start)

httpd_start

;;

stop)

httpd_stop

;;

restart)

httpd_stop

httpd_start

;;

*)

echo "Usage: httpd start|stop|restart!"

;;

esac

注意:以下两行内容是服务能够在chkconfig里添加的必要代码

#chkconfig:345 85 15

#description:Start and stop the Apache HTTP Server

2)把编写的启动脚本赋予执行权限,(添加到系统服务中)

-rwxr-xr-x 1 root root 496 Jul 18 10:12 httpd

3)重新加载守护进程,启动服务

[[email protected] ~]# systemctl daemon-reload #先加载守护进程,否则无法启动服务

[[email protected] ~]# systemctl start httpd

[[email protected] ~]# netstat -lnpt|grep http

tcp6 0 0 :::80 :::* LISTEN 1077/httpd

4)设置开机自启动

[[email protected] ~]# chkconfig --add httpd

5)查看开机自启动结果:

[[email protected] ~]# chkconfig --list|grep httpd

httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

6)apache的安装路径:

/usr/local/apachectl

[[email protected] apache]# ls

bin build cgi-bin conf error htdocs icons include logs man manual modules

原文:https://blog.51cto.com/1283684/2511576

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值