Synchronise PHP CLI and CGI versions

Apache reports PHP Version 7.1.19 via phpinfo().

CLI reports PHP 7.1.25 (cli) via php -v.

I’ve tried editing httpd.conf to change

LoadModule php7_module libexec/apache2/libphp7.so 

to

LoadModule php7_module local/Cellar/php@7.1/7.1.25/lib/httpd/modules/libphp7.so 

but when I restart Apache, there is an error and it doesn’t start until I change it back.

I used Homebrew to install and update PHP on Mojave.

How can I get Apache to use the same version as CLI with the same php.ini file, and preferably have both of them automatically update at the same time?