Start, stop or restart Apache Web Server from terminal on Mac OS

Start, stop or restart Apache Web Server from terminal on Mac OS
Posted by Gulab Bisht

Make your life easier by using the terminal to start, stop or restart Apache web server on Mac OX by simply executing the apachectl commands.

Start Apache server command:

sudo /usr/sbin/apachectl start

or

sudo apachectl start

 

Stop Apache server command:

sudo /usr/sbin/apachectl stop

or

sudo apachectl stop

 

Restart Apache server command:

sudo /usr/sbin/apachectl restart

or

sudo apachectl restart

 

And yes it's not always necessary to check what the status of Apache is, you can simply run the restart command mention above without worrying about whether is running or stopped.

Restart command is also very helpful if you make any changes related to your Apache server configuration in httpd.conf. And sometimes just restart the server to before starting debugging why the website is not responding or something wrong with your Apache PHP setup.