Useful Apache2 Configs

PHPmac – The Largest Online Resource Totally Dedicated to Mac Users of PHP: Additional Useful Apache2 Config Settings by: Eric Taylor (heavyboots) Posted: 29-Dec-04, 19:32:48

After completing your install of apache2 as per the phpmac.com 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/httpd.pid
#

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 MacOSXHints.com, by the way.

Hope these tips helps others!

This entry was posted in computer. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

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=""> <strike> <strong>

  • Word of the Moment

      books have knowledge, knowledge is power, power corrupts, corruption is a crime, and crime doesn't pay..so if you keep reading, you'll go broke
  • You can LIVE CHAT with me!

  • MyDiet

  • iPhone

  • Asides

    • Day Grid Balancer . David Seah writes, "I really suck at work-life balance, and have started to crave some way of visually representing the essential elements of a good ...

    • Tweetie for iPhone and the Mac too - atebits. Hesitant to get another Twitter application for my phone but due to good reviews I was looking at their site and then downloaded the desktop ...

    • Function Reference « WordPress Codex. Many questions can be answered here, and definitely a useful stop before heading over to the user forum to ask: The files of WordPress define many ...