Your own Mac Cloud (WebDAV) Service

Written on:April 13, 2012
Comments are closed

In a previous article I outline my thoughts about Cloud Services, iCloud and available options for accessing data from my home system on my iPad when traveling. The article ended with me mention that the best solution was to setup my own “Web-based Distributed Authoring and Versioning protocol” (WebDAV) solution. I did not provide the details on “the how” since there are many good articles available on the Net that outline how to activate WebDAV on a standard OS X system. However, I notice that lately there was a large increase in the page views of my artilce on this topic. Therefore I decided to write this article to provide the details on how to setup up your own Cloud using WebDAV on a non-server version of OS X, such as Snow Leopard and/or Lion.

  1. Login as a user with Admin privileges

  2. Disable Web Sharing by open the System Preferences window, and ensure that Web Sharing is turned off in the Sharing pane.
    UPDATE: For Mountain Lion instructions see Footnote[1].

  3. Editing the Apache configuration files.
    The next steps require us to use the Terminal app found in the Utilities sub-folder of the Applications folder:
    • Open the Terminal and change to the directory where the first config file is located:

      $ cd /etc/apache2

    • We will need to use the sudo command to open and edit the httpd.conf file using your favorite plain text editor. Since I use TextMate, all I need to do is to enter:

      $ sudo mate httpd.conf

      Optionally you can use the following command using OS X’s TextEdit:

      $ sudo /Applications/ /etc/apache2/httpd.conf

      NOTE: You will be prompted to enter the password of the admin account you are logged in with.

    • Search for the following line ”Include /private/etc/apache2/extra/httpd-dav.conf”. If it starts with ‘#‘, simply remove the ‘#’ at the beginning of the line, this will uncomment the line.

    • Save the changes to httpd.conf and quit the editor.

  4. Editing the WebDAV Configuration Files
    The WebDAV module will be loaded next time the Apache Web Server is started up and will be looking for WebDAV configurations such as which folder should be shared.

    • Let’s go and edit the file by changing to the extra directory:

      $ cd /etc/apache2/extra

    • We will use the sudo command to open and edit the httpd-dav.conf file.
      NOTE: You will maybe asked again to enter the admin password.

      $ sudo mate httpd-dav.conf

    • Delete the existing Alias and Directory configurations and replace them with the following:

      Alias /webdav “/Library/WebServer/WebDAV”

      <Directory “/Library/WebServer/WebDAV”>
        Dav On
        Order Allow,Deny
        Allow from all
        AuthType Basic
        AuthName WebDAV-Realm
        AuthUserFile “/usr/webdav.passwd”
        <LimitExcept GET OPTIONS>
          require user myipad

    • Save the changes to httpd-dav.conf and quit the editor.

  5. Creating your WebDAV User account
    The step above references a password file, /usr/webdav.passwd, and identifies the user ‘myipad’. This is done to add some level of security by not using an existing user name and password. Feel free to change it to anything you like.
    • To create the WebDAV user account execute the following command:
      NOTE: You may be prompted for again for the admin password before being prompted to set the password for the new WebDAV user that is being created.

      $ sudo htpasswd -c /usr/webdav.passwd myipad

  6. Create Directories and setting File Permissions
    In Step 3 we defined /Library/WebServer/WebDAV as the directory location for our Cloud storage. We need to cread the direcory and assign the appropriate file permissions.
    NOTE: The reason for not using a exiting direcory is again for security reasons. Files located in this particular folder will be ownedby the web server, and a separate security authority will govern access to the files.
    • The Terminal should still be open and we should still be in the /etc/apache2/extra directory.
    • The following commands will create the required WebDAV directories:

      $ sudo mkdir -p /Library/WebServer/WebDAV
      $ sudo mkdir -p /usr/var

    • The next three command will set the appropriate permissions on the files and directories:

      $ sudo chown -R www:www /Library/WebServer/WebDAV
      $ sudo chown -R www:www /usr/var
      $ sudo chgrp www /usr/webdav.passwd

  7. Restarting the Web Sharing
    That’s it, all that is left is to open the System Preferences window, and enabling Web Sharing by checkmarkin its box in the Sharing pane. This will now turn on Apache including the WebDAV service. You can now access your own Cloud Service!
    UPDATE: For Mountain Lion instructions see Footnote[2].

To learn how to gain access from your iPad apps, read my Accessing your own WebDAV server article.

  1. Update for Mountain Lion users, as per Apple’s Support page:

    OS X Mountain Lion does not include Web Sharing as an option in the Sharing preference pane. Mountain Lion does include the Apache HTTP Server, an open-source web server.

    By default, web sharing is disabled in Mountain Lion. But to make sure it is, there is no harm to enter the command again. Open the terminal app and enter:

    sudo apachectl stop  ↩

  2. To restart/start web sharing enter:

    sudo apachectl restart


    sudo apachectl start  ↩