How to Edit Apache’s httpd Startup Script

Generally, if Apache is compiled manually, it does not come with a startup script. In other words, users cannot start/stop/restart it with a simple /etc/init.d/httpd(start|stop|restart).
In fact, the source code already includes a startup script. We just need to modify it a bit and add Apache to the system’s SysV services.
The source package httpd-2.x.x/build/rpm contains httpd.init
The copy command is as follows:

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

After copying, note that there are three main places that need to be modified:

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

Please change the corresponding paths according to your actual setup!

Then run the following commands:

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

This way, you can start, stop, and restart Apache using the following commands:

/etc/init.d/httpd start
/etc/init.d/httpd stop
/etc/init.d/httpd restart

Leave a Comment

Your email address will not be published. Required fields are marked *

中文 EN
🚀

RedGate VPN

免费节点太挤太慢?
升级高速稳定专线

立即体验 →

告别卡顿

RedGate VPN
全球高速节点

免费下载 →
Scroll to Top