Mac OS x Restart Apache Web Server

last updated in Categories ,

How do I restart Apache web server under Mac OS X operating systems?

The apachectl command act as Apache HTTP Server control interface. It can be used to start, stop, and restart the Apache web server from command line.


Open a terminal and type any one of the following command:

sudo apachectl restart


sudo apachectl -k restart
Fig.01: Restarting Apache under Mac OS X
Fig.01: Restarting Apache under Mac OS X

Task: Stop Apache Web server

sudo  apachectl -k stop

Task: Start Apache Web server

sudo  apachectl -k start

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


12 comment

  1. The software to start/stop (load/unload) services is called “launchctl”. From the man page:

    launchctl interfaces with launchd to load, unload daemons/agents and generally control launchd. launchctl supports taking subcommands on the command line, interactively or even redirected from standard input.
    These commands can be stored in $HOME/.launchd.conf or /etc/launchd.conf to be read at the time launchd starts.

  2. @Robert, I will look into it.

    @Leaman, the apachectl command works in two modes:
    a) Sys v style mode – One line command mode which take args like start, restart, and stop, and translating them into appropriate UNIX signals to httpd.

    apachectl start | stop | restart | graceful|graceful-stop

    b) Traditional UNIX mode with lots of options for testing and debugging. In this mode it can act as a simple front-end to the httpd command that simply sets necessary environment variables and then invokes httpd, passing through any command line arguments.

    apachectl -t
    apachectl -k stat | stop
    apachectl -d /webroot


  3. SUM-IT:~ sumitgupta$ apachectl -k graceful
    httpd: Syntax error on line 488 of /private/etc/apache2/httpd.conf: Syntax error on line 8 of /private/etc/apache2/other/+entropy-php.conf: Cannot load /usr/local/php5/ into server: dlopen(/usr/local/php5/, 10): Symbol not found: _libiconv\n Referenced from: /usr/local/php5/lib/libintl.8.dylib\n Expected in: /usr/lib/libiconv.2.dylib\n
    SUM-IT:~ sumitgupta$

    this is the problem i am facing please help…..

  4. i receive an error when I try to restart apache with: sudo apachectl restart
    the error reads: /urs/sbin/apachectL: line 73: unlimit: open files: cannot modify limit: invalid argument

    can anyone help! please.

  5. @Javier, I’d say there is an error in your httpd.conf file. Open it up in the plain-text editor of your choice–one that shows line numbers–and look at line 73. There is either a syntax error or an invalid argument for the option contained on that line.

    Good luck!

    1. lemanc,
      i went to httpd.conf file and line 73 is ‘LoadModule include_module libexec/apache2/ ‘ do you know anything about this kind of issue?
      thanks in advanced!

Leave a Comment