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