This question is not a great fit for SO, but in brief: Environment variables can be set for any environment, not just the operating system. Like your web server, for example. I have the following in
/etc/httpd/conf.d/variables.conf which is included into certain virtual hosts in my main Apache config:
#Config for web apps SetEnv DB_CONNECTION "mysql" SetEnv DB_HOST "192.168.242.1" SetEnv DB_USERNAME "dbuser" SetEnv DB_PASSWORD "dbpass" SetEnv DB_DATABASE "dbname"
This file can be protected with permissions to ensure only the web server itself can read them. And I can have multiple files, if I have multiple apps or virtual hosts.