VPN技术 · 2023年11月10日

编辑Apache的httpd启动脚本

修改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
OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.

登录免费注册