A few weeks back I helped a friend build PHP on a server with a non-standard directory structure. Changing the structure to use common defaults wasn’t an option, so we needed to adjust the PHP configure script to point to the pertinent places. Here is what we came up with:
export CPPFLAGS="-I/home/apps/include -I/home/apps/include/mysql"
export LDFLAGS="-L/home/apps/lib -L/home/apps/lib/mysql"
This will build PHP using an apxs utility that resides in /home/apps/bin/apxs, and will look for the MySQL, libxml and zlib libraries and headers in /home/apps/lib and /home/apps/include.