Monday, November 12, 2007

Leopard Uses Apache 2

Those upgrading from Tiger to Leopard will notice that the webserver has been upgraded to Apache 2 - 2.2.6 to be exact. For my simple server, I don't notice any difference, but a list of changes can be found here. The default PHP version included is 5.2.4.

One thing you will notice is that the configuration files have been moved from their previous home at /etc/httpd, to /etc/apache2. Listing the contents of that directory reveals that the files are organized slightly differently:

drwxr-xr-x 14 root wheel 476 4 Nov 01:36 extra
-rw-r--r-- 1 root wheel 17642 4 Nov 01:36 httpd.conf
-rw-r--r-- 1 root wheel 12958 23 Sep 21:11 magic
-rw-r--r-- 1 root wheel 28782 23 Sep 21:11 mime.types
drwxr-xr-x 4 root wheel 136 23 Sep 21:11 original
drwxr-xr-x 5 root wheel 170 4 Nov 01:44 other
drwxr-xr-x 2 root wheel 68 23 Sep 21:12 users


The familiar httpd.conf is still there, and serves essentially the same function. The various functions that are included in the httpd.conf file, however, such as php and virtual hosts, have been separated into the various directories and referenced with Include lines.

Changing the Defaults
Delving into httpd.conf, the ServerAdmin line can be changed to a valid email address, and you may want to change the DocumentRoot line from "/Library/WebServer/Documents", depending on how you organize your server. If you do change it, be sure to change the Directory "/Library/WebServer/Documents" line to the same directory.

I also like to change the DefaultType line to DefaultType application/octet-stream, so that any unknown mime types will be downloaded by the user, instead of output as a stream of garbage characters.

Virtual Hosts
I uncommented the virtual hosts line, since I use them, to read Include /private/etc/apache2/extra/httpd-vhosts.conf.

The extra/httpd-vhosts.conf file should include the virtual host info you would previously have put in httpd.conf, which for me includes NameVirtualHost *, and a series of VirtualHost definitions.

PHP
You may have noted the following line down at the bottom of the httpd.conf file - Include /private/etc/apache2/other/*.conf, meaning that any conf file in the 'other' directory will be parsed, including other/php5.conf. However, one must uncomment this line in httpd.conf to activate php functionality:
LoadModule php5_module libexec/apache2/libphp5.so


Finally I change the line in other/php5.conf to read AddType application/x-httpd-php .php .html, so that I can name my php files with regular .html extensions.

No comments: