Apache的启动脚本httpd编辑

一般情况,如果是手动编译的话,apache是没有启动脚本的,也就是说用户不能通过简单的/etc/init.d/httpd(start|stop|restart)来启动/关闭/重新启动。
其实在源码里已经有启动的脚本,我们要修改下即可,把Apache加入系统SysV服务中来。
在源码httpd-2.x.x/build/rpm中存在httpd.init
拷贝命令如下:

cp httpd.init /etc/init.d/httpd

拷贝之后,注意其中有三处主要的地方需要修改下的:

httpd=${HTTPD-/usr/local/apache/bin/httpd}
pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid}
CONFFILE=/usr/local/apache/conf/httpd.conf

请根据自己的实际情况更改相应的路径!

然后运行如下命令:

chmod +x /etc/init.d/httpd
chkconfig --add httpd
chkconfig --level 2345 httpd on

这样一来,启动、停止、重启Apache就可以用以下方式了:

/etc/init.d/httpd start
/etc/init.d/httpd stop
/etc/init.d/httpd restart
zh-CN Chinese (Simplified)
X