/etc/init.d/apache2 stop | start | restart works but I was looking in the man pages for apache and apache2, and the only thing I could see was:

apache2ctl stop | start | ...

Can someone provide an explanation of the second command and why it doesn't work?

  • 1
    On my system both commands/scripts are working! – Khaled Nov 20 '10 at 14:41

The apachectl script can operate in two modes. First, it can act as a simple front-end to the httpd command that simply sets any necessary environment variables and then invokes httpd, passing through any command line arguments. Second, apachectl can act as a SysV init script, taking simple one-word arguments like start, restart, and stop, and translating them into appropriate signals to httpd.

You CAN use apachectl through a simple bash script, to simply wrap the calls. I.e., /etc/init.d/httpd has a start command that calls apachectl start, etc..

HOWEVER, most Linux distributions provide their own init script, /etc/init.d/httpd (or similar), that uses the SysV macros such as daemon, killproc, etc.. So basically, they do the same thing, but are provided/maintained by different groups. In general, I personally prefer the init script simply because its more in line with the rest of the daemons on my system.

Hope this clarifies things for you!



We don't use the apachectrl script and I maintain a Linux distribution.

We start apache by calling HTTPD directly and before starting, we make sure it's not already running and there is no PID file left behind.

To stop Apache (httpd), we send it the kill -TERM command.

We've been doing it this way for many, many years -- it just works for us this way. Simple and easy...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.