You need to make sure your environment is ready. Install bison, flex, autoconf, libtool and of course gcc and make.

Next, install the command-line version of PHP
% cd php4
% ./configure --with-mysql=/usr --with-pgsql --with-zlib \
  --enable-inline-optimization --with-config-file-path=/etc
% make
% make install
Test It
% /usr/local/bin/php -v
4.3.0-dev