Mac OS X Start / Stop / Restart Apache Web Server

How do I start or stop Apache/Apache 2 web server using a shell prompt option under Apple OS X (macos) UNIX operating systems?

The apachectl command act as Apache HTTP Server control interface. When you edit the Apache config file /etc/apache2/httpd.conf, you need to reload or restart the web server. Open the terminal application and type the following commands:

ADVERTISEMENTS

To stop Apache web server, enter:

sudo apachectl stop
OR
sudo apachectl -k stop

To start Apache web server again, enter:

sudo apachectl start
OR
sudo apachectl -k start

To restart apache web server, enter:

sudo apachectl restart
OR
sudo apachectl -k restart

To run a configuration file syntax test

sudo apachectl configtest

To reload apache web server after editing the config file

First edit the config file, run:
$ sudo vi /etc/apache2/httpd.conf
Make changes as per your needs. Close and save the file. To reload new changes, run:
sudo apachectl graceful
OR
sudo apachectl -k graceful

Sample session from above commands

Fig.01: apachectl in action on macOS

Fig.01: apachectl in action on macOS

You can displays a brief status report by visiting the url http://localhost:80/server-status in the web browser of your choice.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
6 comments… add one
  • Antony Jul 14, 2012 @ 19:26

    For some interesting reason, apache keeps spawning off new process however I kill it. I tried apachectl and kill -SIGTERM but apache would be killed and another process will be spawned right away.
    Can you tell me why?

  • flamencoman Jul 24, 2012 @ 10:31

    I have the same problem as you Antony.
    I’ve used MAMP and then switched to Mac’s default Apache and problem still exists.
    I think it is somehow related to xdebug. I’ll try zend_debugger. If that doesn’t work, I’m switching to another operating system.

  • Evaristo Coimbra Oct 10, 2013 @ 22:53

    in /Applications/XAMPP/xamppfiles/xampp include inicial line sudo apachectl stop

  • Miguel A. Acevedo Nov 15, 2013 @ 19:34

    404-not found
    could not be satisfied

  • Vinit Apr 1, 2016 @ 21:30

    Use this to stop the apache server
    sudo /usr/sbin/apachectl stop

  • Michael Buckenmeyer May 1, 2017 @ 0:38

    Thank you! I was tinkering around with the built-in Apache web server because I’ll be messing around with learning some HTML and CSS on my own. I found a page explaining how to start and use it, but it didn’t say how to end the process. I didn’t notice any performance change but I also didn’t want wayward processes running on my machine. Many thanks!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.