Mac OS

Mac OS is a Unix-based operating system and graphical user interface developed by Apple Inc.

More information about Mac OS can be found at:

Setup Apache web server on Mac OS X


Operating system used
Mac OS X 10.7 (Lion)

Software prerequisites

  1. An Apache 2.2 web server is already installed on the Mac OS X, but by default not enabled.
    To determine which version is installed, open the Terminal application and type: httpd -v

    You should see:
    Server version: Apache/2.2.20 (Unix)
    Server built: Sep 8 2011 18:13:15

  2. Click the apple icon (top left corner) and select "System Preferences..."

    Click Apple icon

  3. Click icon "Sharing"

    Select Sharing

  4. Enable "Web Sharing".

    Select web sharing

  5. Two default websites are setup
    • Your personal website: http://<computer_name>/~<accountname>
      The docroot is located at: /Users/<accountname>/Sites

    • Your computers website: http://<computer_name>/
      The docroot is located at: /Library/WebServer/Documents

    Note: The apache documentation can be accessed by http://<computer_name>/manual/

  6. Enter the URLs in your web browser to check if the webserver is running.

    Example 1: http://mac/~robertlie

    Mac default page 1

    Example 2: http://mac/

    Mac default page 2

    If the default index.html pages are not displayed, the URL http://<computer_name> can not be resolved.
    • Open the Terminal application
    • Type: cd /private/etc
    • Edit the hosts file, type: sudo vi hosts
    • Add the following line:    mac
    • Save the file

  7. If you want to use a fully qualified domain name (e.g. mac.mobilefish.intranet) instead of a computer name, do the following:

    • Open the Terminal application.
    • To check what your current hostname is, type: hostname
    • Change your hostname:
      • sudo scutil --set HostName <new_hostname>>
      • Enter your password to make the change.

      For example:
      sudo scutil --set HostName mac.mobilefish.intranet
    • Edit the hosts file, add the following line:    mac.mobilefish.intranet
    • Edit /etc/apache2/httpd.conf and change line:
      ServerName mac.mobilefish.intranet:80
    • Restart apache web server:
      sudo apachectl restart
    • Your website can now be accessed by the fully qualified domain name.
      For example:


  8. The Apache web server configuration files can be found at:

    The Apache web server log files can be found at:

    The stop, start or restart Apache web server from the Terminal application, type:
    sudo apachectl stop
    sudo apachectl start
    sudo apachectl restart