Introduction
The web sever is an Apache 2 installation with PHP and a few modules installed.
Apache
The first step is to download the latest stable build of the Apache Web Server. This can be found here. I prefer to use the stable version 2 branch. Some people prefer the 1.3 branch, which is far more thoroughly tested. The 1.3 branch is what is included with OS X by default, and you can use this if desired. Once downloaded, Apache needs to be compiled. Use the following commands:
./configure --prefix=/Library/Apache2 --enable-mods-shared='auth-digest dav dav-fs dav-lock expires headers info mime-magic rewrite speling ssl unique-id usertrack vhost-alias' --disable-cgi --enable-ssl --with-ssl=/usr/local
make
sudo make install
Mod vhost MySQL
Mod vhost is used to be able to dynamically create virtual hosts. This can be downloaded from the modules site. Be sure to download the Apache 2 version. It can be compiled and installed using the following command:
sudo /Library/Apache2/bin/apxs -cia -I /usr/local/mysql/include -L /usr/local/mysql/lib -lmysqlclient mod_vhost_mysql.c
PHP
The next step is to install PHP. Download the latest stable version of PHP from the PHP site. It must then be compiled and installed. In order to get all the nice features there are a few extra packages that need to be installed first. In particular the JPEG tools. In order to get these, go to the TeXShop site and download the II2 installer package. Install this, and select ‘Known Packages i-Directory’. Install the ‘JPEG Tools and Library’ package. Once that is done, PHP can be compiled and installed with the following commands:
./configure --prefix=/Library/PHP --with-apxs2=/Library/Apache2/bin/apxs --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql=/usr/local/mysql --with-zlib=/usr --with-gd --with-png-dir=/usr/local/lib --with-jpeg-dir=/usr/local/lib --with-tiff-dir=/usr/local/lib --with-mime-magic --with-xml --with-pear --enable-sockets --enable-shared
make
sudo make install
sudo /Library/PHP/bin/pear install DB
Configure SSL
A self-signed certificate can be used to offer a level of protection for some parts of the site. Note that this website does not contain sensitive information, and thus security is only a precaution, not a requirement. These instructions are based on the information here.
cd /Libraby/Apache2/conf
sudo -s
mkdir ssl
chmod 700 ssl
cd ssl
gzip -c --best /var/log/* > random.dat
openssl rand -rand file:random.dat 0
openssl req -keyout privkey-2007.pem -newkey rsa:1024 -nodes -x509 -days 365 -out cert-2007.pem
chmod 600 privkey-2007.pem
chown root privkey-2007.pem
Configure WebDAV
WebDAV is useful to work with iCal and other MacOS X features.
cd /Library/WebServer
sudo -s
mkdir davlocks
chown www:www davlocks
chmod 755 davlocks/
mkdir ical
chmod 775 ical
chown www:www ical
htdigest -c /Library/WebServer/.davusers realm username
The
Configure Apache
This is simply a matter of editing httpd.conf, which is in the /Library/Apache2/conf/ directory.