Start Apache HTTP Server Service on Mac OS X Mountain Lion

Apache HTTP Server (httpd) was included out of the box of Mac OS X Mountain Lion (10.8) if you don’t know already. Prior to Mac OS X 10.8 (Mountain Lion) can simply turn on “Web Sharing” to start Apache Web Server service, but from 10.8 onward you’ll need to use command line to start the Apache web server.

No Web Sharing Option on Mac OS X Mountain Lion

osxdaily.com mentioned here that we can use apachectl command to start and stop apache web server service from command line like the following:

sudo apachectl start
sudo apachectl stop

Another way to start and stop apache web server is using the httpd command like the following:

sudo httpd -k start
sudo httpd -k stop

If you start the apache web server using apachectl command, you only able to stop it using the apachectl command and not the httpd -k command. This is also works vice versa.

Here’s an example on how to do it in terminal:

Start and Stop Apache Web Server using apachectl Command on Mac OS X Mountain Lion

Start and Stop Apache Web Server Using httpd -k Command on Mac OS X Mountain Lion

From both pictures above, I uses netstat -an | grep LISTEN command to show all open services on my Mac computer. A line indicating a service is LISTENING on port 80 (tcp46 ... *.80 ... LISTEN) means a web server is currently running on my Mac computer. And when those line are not in, then the web server is off.

The default apache web server configuration are in /etc/apache2/httpd.conf file.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

CAPTCHA Image

*

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>