Building PHP 5.3.0 with Tidy Support

I dug around a bit, but most resources I came across on Google were about using the tidy extension for PHP rather than doing a custom build of PHP that included the tidy extension. Once I figured the details out, I thought I’d share. They admittedly seemed somewhat obvious after the fact, though also were not communicated as explicitly as I would have liked anywhere that I could see.

You’ll need a system with a CVS client installed to do this. The system I intended to build on didn’t have one, so I used my laptop, did a CVS checkout, made a gzipped tarball out of the CVS checkout directory, used scp to push it up to the remote server, and decompressed and extracted the archive from there.

  1. Download a PHP 5.3.0 tarball and decompress it.
    $ wget -c http://us2.php.net/get/php-5.3.0.tar.gz/from/a/mirror
    $ tar -zxf php-5.3.0.tar.gz
  2. Follow the anonymous checkout instructions to download tidy. Enter the first command shown here, press Enter without entering anything when prompted for a password, then enter the second command shown here.
    $ cvs -d:pserver:anonymous@tidy.cvs.sourceforge.net:/cvsroot/tidy login
    Logging in to :pserver:anonymous@tidy.cvs.sourceforge.net:2401/cvsroot/tidy
    CVS password:
    $ cvs -z3 -d:pserver:anonymous@tidy.cvs.sourceforge.net:/cvsroot/tidy co -P tidy
  3. When configuring the PHP build and specifying the path for tidy, just point to the root CVS checkout directory.
    $ ls tidy
    CVS  CVSROOT  bin  build  console  experimental  htmldoc  include  lib  src  test
    $ cd php-5.3.0
    $ mkdir build/php_build
    $ ./configure --prefix=`pwd`/build/php_build --with-tidy=../tidy
    $ make
    $ make install

I didn’t run into any problems when following this process. php -m shows the tidy module and it appears to run without issue. Hope this helps someone else.

2 Comments

  1. Giorgio Sironi says:

    Why rebuilding php instead of using the extension? I think the functionality is the same but the extension does not force you to recompile everything.

  2. admin says:

    @Giorgio I don’t have administrative access to the remote server I’m building on. This was intended to be a local build used for running PHP CLI scripts. Even if I use the PECL installer, I would still need a local installation of the tidy library, which that server didn’t have. As such, I had to download it to compile the extension against.