How To Integrate Fink's Apache with MacOS X

slur

Geek / Hedonist
I managed to get the Fink version of Apache working seamlessly with MacOS X. It wasn't as simple as simply choosing "Update" but it wasn't all *that* difficult either. In order to be totally integrated with MacOS X the Fink install of Apache needed to have several things made to work:

1. Startable and stoppable with the button in the Sharing control panel.
2. Able to start at bootup time.
3. Able to see my user directories.
4. Able to use the Fink-installed version of PHP.

So here's what I did. Before you follow these steps you should open the terminal and become super-user:

su
<root password>


1. Start and Stop with the Web Sharing button.
When you press the Web Sharing Start button MacOS X starts Apache by invoking apachectl. If MacOS X can't find apachectl it won't start it, and if you've installed Apache using Fink this button will still start the original installed version. The simplest way to get this working is to replace the original apachectl with a symbolic link:

rm /usr/sbin/apachectl
ln -s /sw/bin/apachectl /usr/sbin/apachectl


Now it'll start with the Web Sharing Start button. However, the Web Sharing panel still can't tell that Apache is running, so the button just sticks in a grayed-out position forever. This is because it can't find the httpd.pid file where it expects it to be (/private/var/run/httpd.pid). Another symbolic link fixes this:

rmdir /sw/var/httpd/run/
ln -s /private/var/run /sw/var/httpd/run


2. Starting up at boot time
In order to start Apache at bootup MacOS X only needs to be able to find apachectl, and we've already taken care of that by making the first symbolic link. No step 2 required...

3. and 4. Configuration Stuff
All these concerns are handled in the httpd.conf file. The simplest way I could see to make the appropriate changes was to compare the Fink version of httpd.conf with the original httpd.conf that Apple supplies and then choose which things to change and which to leave alone. So I used the diff command and then opened the resulting file in TextEdit:

diff >httpd_diff.txt /sw/etc/httpd/httpd.conf /private/etc/httpd/httpd.conf
open httpd_diff.txt


Armed with this information I was able to make the appropriate changes and get PHP working without a hitch. What follows is a synopsis of the changes I made, in a semi-diff format. Each line that begins with '-' was removed, and each one beginning with '+' was inserted. So each pair of lines indicates a line that was replaced, dig?

To make these changes use your favorite text editor, such as pico:

pico /sw/etc/httpd/httpd.conf

Of course if you've customized your Apache configuration you should make the appropriate adjustments.

---------- BEGIN LIST OF CHANGES ----------

- ScoreBoardFile /sw/var/httpd/run/httpd.scoreboard
+ ScoreBoardFile /private/var/run/httpd.scoreboard

- MinSpareServers 5
+ MinSpareServers 1

- MaxSpareServers 10
+ MaxSpareServers 5

- StartServers 5
+ StartServers 1

- MaxRequestsPerChild 0
+ MaxRequestsPerChild 100000

- ServerAdmin root@localhost.fellowship.de
+ #ServerAdmin webmaster@example.com

- #ServerName localhost.fellowship.de
+ ServerName 127.0.0.1

- DocumentRoot "/sw/share/httpd/htdocs"
+ DocumentRoot "/Users/my_user_name/Sites"

- &lt;Directory "/sw/share/httpd/htdocs"&gt;
+ &lt;Directory "/Users/my_user_name/Sites"&gt;

- UserDir public_html
+ UserDir "Sites"

- DirectoryIndex index.html
+ DirectoryIndex index.html index.php index.pl

- ErrorLog /sw/var/httpd/log/error_log
+ ErrorLog "/private/var/log/httpd/error_log"

- CustomLog /sw/var/httpd/log/access_log common
+ #CustomLog "/private/var/log/httpd/access_log" common

- ScriptAlias /cgi-bin/ "/sw/share/httpd/cgi-bin/"
+ ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables/"

- &lt;Directory "/sw/share/httpd/cgi-bin"&gt;
+ &lt;Directory "/Library/WebServer/CGI-Executables"&gt;

Remove this line:
AddLanguage zh-tw .tw

Add this line to the end for individual user privileges:
Include /private/etc/httpd/users

For PHP add these lines to the appropriate sections of httpd.conf:

AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

LoadModule php4_module lib/apache/1.3/libphp4.so
AddModule mod_php4.c

---------- END LIST OF CHANGES ----------
 
Yo, the default DocumentRoot is actually this:

DocumentRoot "/Library/WebServer/Documents"

...not the User/username/Sites folder. The Sites directory in my home directory happens to be my preference, but do what you like best!
 
Back
Top