This gist took PHP - Manually Installing the MongoDB PHP Driver, as reference.
First locate your php-config file. To do so, you can trace it with locate php-config. It will be something like this:
It's the file that has all compiled php settings, and it will be used to tell config command, wich PHP should be compiled for.