How and where to put environment variables for php and ini file that gets read when nextcloud or any web app is running from apache

I have bunch of IP addresses hard coded in config.php and /etc/php/7.4/apache2/php.ini

I want to know how can I set IP address in an environment variable and where so it can be read by php.config as well as php.ini.