Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'd like to have a single command that'll restart Apache on any *nix OS. Currently I'm working with Ubuntu, which has

  • /usr/sbin/apache2ctl
  • /usr/sbin/service
  • no apachectl
  • no httpd

and Scientific Linux CERN 5, which has

  • /usr/sbin/apachectl
  • /etc/init.d/httpd
  • no apache2ctl
  • no service

I'd like to avoid using a hack like which service 2>/dev/null || which /etc/init.d/httpd

share|improve this question

2 Answers 2

up vote 2 down vote accepted

apachectl / apache2ctl is the apache built in tool to control apache, it's probably the right tool to use in your case as it comes with apache it will be the some on all OS.
apachectl is normally for Apache 1.x and apache2ctl for Apache 2.x.
If SLC5 comes with Apache 2.x it's quite strange but you could run both apachectl and apache2ctl in your script.

share|improve this answer

You could use a script that checks which apachectl is installed and then run the appropriate one.


if [ -e /usr/sbin/apacche2ctl ]
    /usr/sbin/apache2ctl restart
elif [ -e /usr/sbin/apachectl ]
    /usr/sbin/apachectl restart
    echo "No Apache control program found"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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