Go here to get started http://us.php.net/manual/en/install.php. Also consider this, this and this.
You will need to read up on how to compile PHP. It is done from the command line so if you aren't comfortable with that, be careful. Also be aware that the specifics for compiling on the Mac are very detailed and one tiny slip results in a hosed install.
Since you are on a Mac look at Marc Liyanage's packages (though I don't know if they have Tidy configured). Also consider using MacPorts to do all of this (especially useful for making sure you have all dependancies installed). If you must do it from scratch please understand that you really need to know what you are doing.
That out of the way:
The basic process is to configure, make, make install.
Here are some sample configurations (do NOT use these. The paths are specific to certain installations and you will have different ones. This is just to show you what the config can look like):
./configure --with-mysql=/Applications/MAMP/Library --with-apxs2=/Applications/MAMP/Library/bin/apxs --with-gd --with-jpeg-dir=/Applications/MAMP/Library
./configure --prefix=/usr/local/apache2/php --with-zlib --with-xml --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql
So you would need to add --with-tidy
to that list along with any of the other config options you need/want.
Here is another example showing make and make install (notice --with-tidy
at the end):
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --infodir=/usr/share/info --with-apxs2=/usr/sbin/apxs --with-curl --with-gd --enable-exif --enable-fastcgi --enable-zip --with-ldap=/usr --with-kerberos=/usr --with-zlib=/usr --enable-ftp --enable-sockets --with-iodbc=/usr --with-config-file-path=/etc --with-openssl --with-xmlrpc --with-xsl=/usr --with-tidy=/usr/bin/tidy
make
sudo make install
Read up on this and be prepared to have to do it several times to get it right (the whole process takes a while, too)