Change php modules directory

I would suggest making /usr/lib64/php/modules a symlink to the folder with the ID. This prevents mixing extensions from different versions of PHP in the long run.

Besides that: You should be able to set it by setting EXTENSION_DIR as environment variable before running PHP's configure. something like

 $ EXTENSION_DIR=/my/location ./configure --with-some-extension

Check the current extension directory with:

php-config --extension-dir

and you can change it by setting extension_dir in php.ini:

extension_dir="/usr/lib64/php/modules"

Don't forget to restart Apache.