I didn't checked this, but as I know if something (e.g. MySQL) is installed without headers files you cannot print in PHP configure options exact dir name.
It means, that
./configure --with-mysql=/usr/local/mysql
works only if you installed mysql with headers.
If not, you have to print
./configure --with-mysql
So, check the same configure options, but without exact names of directories.
Gregor63