My issue was not identical, but since this question was the first to pop up with answers that were ultimately very helpful, I will add my comments.
I was having trouble getting PHP (under Centos7 running in a docker container) to use MySQL due to directory configuration - although I was using pre-built binaries and not compiling anything. Although the various pdo and mysqlnd.so modules and .ini files were installed in my container (just using standard yum install php72 and all the other stuff specified in the PHP install wizard), they were not in the default places that PHP was looking for them. I have no idea why. Maybe it's some kind of docker thing?
Anyway, to solve the issue I had to echo an extension_dir directive to my PHP.ini and ALSO set the PHP_INI_SCAN_DIR env variable. These are the relevant commands from my Dockerfile
ENV PHP_INI_SCAN_DIR=/etc/php.d/ RUN echo 'extension_dir = "/usr/lib64/php/modules"' >> /etc/opt/remi/php72/php.ini
I hope this doesn't result in getting module conflicts later down the track as @johanes warns.
EXTENSION_DIR=/usr/lib64/php/modules phpize.