Compiling Mod_Bonjour on OS X 10.11 El Capitan


Remember the good old days when  OS X ‘s Apache came with mod_bonjour and user sites were broadcast automagically. It can be a useful feature especially in a multiuser or lab setting. Well never fear, you can activate it once again. All you need to do is compile and install mod_bonjour for Apache on El Capitan.

What can mod_bonjour do? It can automate three types of tasks over your LAN:

  1. Broadcast a link to a default website for your computer.
    • http://computername.local.
  2. Broadcast links to other webpages which will be seen as paths of the default web address.
    • http://computername.local./resource1
    • http://computername.local./resource2
  3. Broadcast a link to a website for each individual user account on your computer .
    • http://computername.local./~username
    • http://computername.local./~anotherusername

All of which require zero configuration once the Apache module has been compiled, loaded, and a few directives set. Pretty nifty huh? So let’s get to it.

This tutorial was made on OS X 10.11.3 with Apache 2.4 and mod_bonjour 23. My text editor of choice is TextMate and it’s command line utility is “mate.” So when you see that command sutitute the text editor that you prefer. Also when you see the placeholder <-myusername-> insert your actual username.


One dependency we have to install is Xcode. You’ll need Xcode’s developer tools in order to follow along with this tutorial so go ahead and Install Xcode.

Temporarily Disable System Integrity Protection

The first thing we need to take into account is that we are intending to modify the /usr/libexec/apache2 directory. This directory is flagged as “restricted” thanks to El Capitan’s new rootless System Integrity Protection feature. We’ll need to temporarily disable SIP to complete this tutorial so read up and follow the instructions on How to work with SIP here.

Compile from source:

O.K. now that you’re back Let’s make a src directory for your source code in your /usr/local, set our ownership, and get into it.

sudo mkdir /usr/local/src
sudo chown <-myusername->:admin /usr/local/src
cd /usr/local/src

Now grab a tarball of mod_bonjour from Apple, open it up and cd into it. The code below downloads mod_bonjour version 23. Check here for the latest version and adjust your commands accordingly.

curl -O
tar zxvf apache_mod_bonjour-23.tar.gz
cd apache_mod_bonjour-23

Now you can make and install.

sudo make install

Success…  has been installed in:


Thats all for working with System Integrity Protection flagged directories so you can reactivate SIP whenever you’re ready.

Loading Apache Modules:

Now on to the final steps. Next we’ll need to open up out httpd.conf and make some changes.

mate /private/etc/apache2/httpd.conf

Uncomment (remove the # symbol) from the following line:

LoadModule userdir_module libexec/apache2/

Now add the following line after the one you just uncommented:

LoadModule bonjour_module libexec/apache2/

Next search for the following line in httpd.conf and uncomment it.

Include /private/etc/apache2/extra/httpd-userdir.conf

Go ahead and save the changes to your httpd.conf.

Editing http-userdir Config File:

At the start of this tutorial we asked “What can mod_bonjour do?” There were three items listed in the answer. Now that we have imported our httpd-userdir.conf we can make those things happen. Open httpd-userdir.conf in your text editor.

mate /private/etc/apache2/extra/httpd-userdir.conf

Now uncomment this line to allow for individual user.conf files to be imported.

Include /private/etc/apache2/users/*.conf

And notice the line that reads: UserDir Sites. That line is what defines document root for the user web sites. What if we want it to be in a different directory? Simple enough, just change the line to this for example: UserDir Sites/mysite. That would make /Users/<-myusername->/Sites/mysite act as the document root for http://computer.local./~<-myusername->. Now take a look at:

<IfModule bonjour_module>
    RegisterUserSite customized-users

RegisterUserSite lets mod_bonjour know that we want to broadcast websites for user accounts on this machine and customized-users limits the broadcast to users who have modified the default index file in their Sites directory. That’s all for exploring mod_bonjour’s user sites.

What bout a default computer website? All we need to do is make the following changes to the IfModule conditional statement like so:

<IfModule bonjour_module>
    RegisterUserSite customized-users

Notice all that we added was RegisterDefaultSite in the If statement. Document root for the default site is set in /private/etc/apache2/httpd.conf and it maps to:


As if that was’t enough, mod_bonjour has one more trick up it’s sleeve. It can register resources (i.e. other websites) that map as subdirectories of the default computer website. For example: http://mycomputer.local/resource.

<IfModule bonjour_module>
    RegisterUserSite customized-users
    RegisterResource <-name-> <-path-> <-port-> <-protocol->

The <-name-> is what will show up in Safari’s bookmarks or favorites bar. The <-path-> is the path of the website relative to document root. You don’t need to enter <-port-> or <-protocol-> since their defaults will suffice. So for example:

RegisterResource phpMyAdmin /phpmyadmin

Will map to:


W00T! We’ve covered all three ways you can broadcast websites via mod_bonjour.

Creating user.conf:

This leads us to creating our user.conf file. Change directories in Terminal to /private/etc/apache2/users/ and write the new file with your text editor.

cd /private/etc/apache2/users/
sudo mate <-myusername->.conf

Once in your text editor, insert the following:

<Directory "/Users/<-myusername->/Sites/">
 DirectoryIndex index.html
 Options Indexes MultiViews FollowSymLinks Includes
 AllowOverride All
 Require all granted

Save the file.

Checking And Restarting Apache:

Almost there… Let’s check our Apache config with:

apachectl configtest

If the Syntax is all good it’s time to restart Apache:

sudo apachectl restart

At this point, let’s check the Apache error log to see if any errors are present when we start Apache.

open -a Console /private/var/log/apache2/error_log

I’ve found the following warning in the Apache error log:

[:warn] [pid 79] mod_bonjour: Cannot stat template index file '/System/Library/User Template/English.lproj/Sites/index.html'.

It’s telling us that mod_bonjour is looking into the OS X User template file to check the file status of an index.html in the ~/Sites directory. It makes sense. Mod_bonjour needs a baseline for comparison to see which users have customized their Sites directory. Since the file and path don’t exist Apache throws a warning in the log. If you want to remove the warning. Open up a terminal session as root and add an index.html at the path listed in the warning.

Oh sweet success!

The only thing that users on your computer and other computers on the local network need to do to see the site links is check the checkbox for showing Bonjour sites in the bookmarks menu or favorites bar of Safari. This setting is found in the Advanced section of Safari’s Preferences.

One Comment

  1. Cuga Rajal
    | Permalink

    I was able to get mod_bonjour compiled and installed in macOS Sierra with the following steps:

    (Based on some hints I found at

    1. before starting, I did the following:

    brew install apr apr-util
    sudo mkdir -p /Applications/
    sudo ln -s /usr/local/opt/apr/bin/apr-1-config /Applications/
    sudo ln -s /usr/local/opt/apr-util/bin/apu-1-config /Applications/
    sudo mkdir -p /Applications/
    sudo ln -s /usr/bin/cc /Applications/

    2. Then I use your build steps: make, sudo make install

    3. Once installed, I can remove the following (although it may be needed again of re-compiling in the future):

    sudo rm -rf /Applications/

Post a Comment

Your email is never published nor shared. Required fields are marked *

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