# How to Set Environment Variables in Apache HTTPD.conf file

**URL:** <https://community.dynatrace.com/t/how-to-set-environment-variables-in-apache-httpd-conf-file/46763>\
**Category:** Troubleshooting\
**Tags:** tagging, apache\
**Created:** [July 29, 2024, 7:42am UTC](https://community.dynatrace.com/t/how-to-set-environment-variables-in-apache-httpd-conf-file/46763 "2024-07-29T07:42:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chiranjitdutta](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chiranjitdutta/32/29757_2.png) [@chiranjitdutta](https://community.dynatrace.com/u/chiranjitdutta)\
**Post date:** [July 29, 2024, 7:42am UTC](https://community.dynatrace.com/t/how-to-set-environment-variables-in-apache-httpd-conf-file/46763/1 "2024-07-29T07:42:18Z")

</div>

# **Description**

Dynatrace automatically detects the metadata values of processes and displays them in UI. However, in circumstances where the metadata cannot be detected, and used for TAGGING or process group Detection etc,&nbsp; we have [Environment variables](https://docs.dynatrace.com/docs/shortlink/process-group-properties#variables) options to set to achieve this.  
Environment variables cover most technologies (Java and non-Java processes like NGINX, Apache HTTP server, FPM/PHP, Node.js, IIS, and .NET.)

# **Issue**

After setting environment variables in the HTTPD file and restarting, the environment variables do not show up in Dynatrace. The below example shows that some environment variables have been set in **/etc/httpd/conf/httpd.conf.** &nbsp;However, even after a restart of the relevant services it doesn’t reflect in the properties and tags section of the Process page.

 ![chiranjitdutta_6-1721728473415.png](https://global.discourse-cdn.com/dynatrace/original/2X/d/d7351e0d911c8b5d687a1fa8fb5d4aae3344ba34.png)

# **Solution**

## **For Linux**

Dynatrace doesn’t support/ apply metadata in environment variables within the Apache httpd.conf file. Httpd.conf is specifically for configuring the Apache web server itself, not for setting environment variables. Also the “SetEnv” is not the correct parameter for this.

There are few options users can try setting the environment variables outside of httpd.conf and letting them influence the processes spawned by Apache

### **Option 1**

- Modify the systemd service file (or similar init script) that starts the Apache service.
  - Example (systemd):  
[Service]  
… (other service configurations)  
Environment=“DT\_CUSTOM\_PROP=TeamName=DevOps,Environment=Production”  
ExecStart=/usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
… (other service configurations)

- This injects the DT\_CUSTOM\_PROP environment variable with your desired metadata before starting Apache. The Apache processes will inherit this variable and Dynatrace can pick it up.
- Make sure the script or systemd service has proper permissions to execute Apache.

After adding the variable and restarting the services it starts reflecting in the Process page.

 ![chiranjitdutta_7-1721728511555.png](https://global.discourse-cdn.com/dynatrace/original/2X/b/b19206a1b9d6ea3d9237855f276f4cf6aa8a1ee2.png)

### **Option 2**

Setting Environment Variables in a Script:

- Create a script that sets the environment variables and then starts Apache.
  - Example (bash script):  
#!/bin/bash  
export DT\_CUSTOM\_PROP=TeamName=DevOps,Environment=Production /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
# Alternatively, use exec to replace the script with Apache process  
# exec /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf

- This script sets the DT\_CUSTOM\_PROP and then executes the Apache process with the environment variable available.

**Important Note:** Remember to adjust the paths and variable names according to your specific setup. Make sure the script or systemd service has proper permissions to execute Apache.

## **For Windows**

There are also many ways to set the Environment variables but that depends on the requirement.

### **Option 1**

Using a Batch or PowerShell Script where Applications started via scripts.

- Create a batch or PowerShell script to set the environment variables and start the application.
- Execute the script to start the application with the desired environment variables.  
$env:DT\_CUSTOM\_PROP = “TeamName=DevOps,Environment=Production” Start-Process “path\_to\_your\_application.exe”

### **Option 2 (recommended/easy way)**

**Modifying the Registry of the** [Service](https://docs.dynatrace.com/docs/manage/tags-and-metadata/setup/define-tags-based-on-environment-variables#variables)

- Open Registry Editor (regedit.exe).

- Navigate to HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Services\\<service\_name\>.

- Create a new key named “Environment” with type REG\_MULTI\_SZ.

- Add string values for your environment variables in the format DT\_CUSTOM\_PROP=TeamName=DevOps,Environment=Production.

- Below is an example of one of the dynatrace service which we applied Environment variable and TAG.

---

<div class="post-metadata">

**Author:** ![AntonPineiro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antonpineiro/32/49_2.png) [@AntonPineiro](https://community.dynatrace.com/u/AntonPineiro)\
**Post date:** [July 29, 2024, 10:31am UTC](https://community.dynatrace.com/t/how-to-set-environment-variables-in-apache-httpd-conf-file/46763/2 "2024-07-29T10:31:27Z")

</div>

Thank you!&nbsp;:money\_mouth\_face:

---

<div class="post-metadata">

**Author:** ![Miguel\_RinconG](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/miguel_rincong/32/29455_2.png) [@Miguel\_RinconG](https://community.dynatrace.com/u/Miguel_RinconG)\
**Post date:** [August 27, 2024, 3:05pm UTC](https://community.dynatrace.com/t/how-to-set-environment-variables-in-apache-httpd-conf-file/46763/3 "2024-08-27T15:05:16Z")

</div>

Thanks!!!

---

<div class="post-metadata">

**Author:** ![prashant\_shinde](https://avatars.discourse-cdn.com/v4/letter/p/5daacb/32.png) [@prashant\_shinde](https://community.dynatrace.com/u/prashant_shinde)\
**Post date:** [September 11, 2025, 9:08am UTC](https://community.dynatrace.com/t/how-to-set-environment-variables-in-apache-httpd-conf-file/46763/4 "2025-09-11T09:08:00Z")

</div>

Chiranjit explained it very well for Apache HTTP Server. We tried for OHS server, but it did not work, If anyone struggling with OHS Server, then try below steps it worked for us. For Oracle HTTP Server passed environment variables in&nbsp;[ohs.plugins.nodemanager.properties File](https://docs.oracle.com/middleware/12213/webtier/administer-ohs/GUID-4A90D621-BF19-4BC0-93CF-EEC242ED850F.htm#HSADM-GUID-4A90D621-BF19-4BC0-93CF-EEC242ED850F)&nbsp;example as follows for process grouping and can be referred for Metadata as well.

environment.DT\_CLUSTER\_ID=Value  
environment.DT\_NODE\_ID=Value
