Through the Operating System

Windows

Control Panel

It is convenient to setup one computer this way, but very cumbersome if you deal with a great number of computers.

Configure operating system environment by opening Control Panel > System window, then going to the Advanced or Advanced System Settings tab and clicking the Environment Variables button.

You can either create a user variable (active only when the current user is logged on), or a system variable (always active on this computer).
It is recommended to use system variables because render farm software sometime launch render using a different user account, or as a service (with the system account).

Group Policy

If you use Group Policy Objects (GPO) to administer your computers, you can simply add Environment Variable Items. The Environment Variables will then be automatically set on all applicable computers.

You can either create a user variable (active only when the current user is logged on), or a system variable (always active on this computer).
It is recommended to use system variables because render farm software sometime launch render using a different user account, or as a service (with the system account).

See Microsoft Help for more details: Configure an Environment Variable Item

NB: as all Active Directory action, it is not immediate, and you have to wait until Active Directory deploy the variable

Linux

Environment variables should be exported in one of your logon (~/.bashrc or ~/.bash_profile/ ...) or init script (depends on your distribution)

Here is an example how to set these variables