我的apache安装目录在 /usr/local/apache 有2种方法可以设置开机启动
方法一: cp /usr/local/apache/bin/apachectl /etc/init.d/httpd vi /etc/init.d/httpd
在#!/bin/sh后面加入下面两行
#chkconfig:345 85 15
#description: Start and stops the Apache HTTP Server.
然后 chmod +x /etc/rc.d/init.d/httpd chkconfig --add httpd
然后可以用setup命令进入服务设置,设置为开机启动
方法二: 将服务加到/etc/rc.d/rc.local中 vi /etc/rc.d/rc.local 添加以下内容 /usr/local/apache/bin/apachectl start