Additional Useful Apache2 Config Settings

Warning: This article/tutorial is more the 45 days old. As such the information contained within could be, by now, out of date. Please read all information to make sure that this article/tutorial will work with your current version of the Operating System

After completing your install of apache2 as per the tutorial, here’s a couple of additional tips to help make it as Mac-compatible as possible.

These edits all take place in your apache2 config file, most likely located in /apache2/conf/httpd.conf.

Default User
The default user for OS X should be www instead of nobody. Search for:

User nobody
Group nobody

and change to:

User www
Group www

.htaccess Security Settings per Apple
Apple now has a rather longer .htaccess denial section (as of the 12-02-04 Security Update). You can duplicate it by searching for the line

# The following lines prevent .htaccess files from being viewed by

and replacing the uncommented Files directive below it with the following three directives

Order allow,deny
Deny from all
Satisfy All

Order allow,deny
Deny from all
Satisfy All

Order allow,deny
Deny from all
Satisfy All

The cgi-bin Directory
Additionally, if you’re planning to keep using the /Library/WebServer folder, don’t forget to change your cgi-bin folder settings. Search for the ScriptAlias line and make it look like this

ScriptAlias /cgi-bin/ “/Library/WebServer/CGI-Executables/”

Using the System Prefs Sharing Panel to Control Apache2
Finally, if you want to be able to use your System Preferences Sharing pane to start and stop your apache2 install, there are a couple of things to do. First is to find the PidFile section and make it look like this

# PidFile: The file in which the server should record its process
# identification number when it starts.
PidFile /private/var/run/

Note that not only has the PidFile path been changed to be in the /private/var/run folder, but also, the IfModule lines have been commented out.

At this point, all necessary modifications have been made to the apache2 conf file–we just need to link up the apachectl for apache2 to replace the one that is installed by default by Apple. So save your httpd.conf file and in Terminal do the following.

cd /usr/sbin/;
mv apachectl apachectl-1.3;
ln -s /apache2/bin/apachectl apachectl;

Basically, this renames the old Apple apachectl to be apachectl-1.3 (and you can even start and stop the original Apple apachectl by using that command). Then it makes a symbolic link from our apache2 folder into the /usr/sbin folder. Now when you start and stop Web Sharing from the System Preferences panel, you should be starting and stopping apache2.

This last tip was gleaned from, by the way.

Hope these tips helps others!

Leave a comment

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