apache set environment variable

How to Set Apache PATH Environment Variable

Sometimes you may need to set Apache PATH environment variable. Typically, the most common way to do this is useing SetEnv command in Linux. Here is our detailed tutorial to set environment variables using SetEnv. However, if that does no work for you, then here is another way to do this.


How to Set Apache PATH Environment Variable

Apache’s Environment variables are stored in /etc/apache2/envvars in Ubuntu, /etc/sysconfig/httpd in Redhat and at /etc/rc.conf in BSD.

Open terminal and run the following command to open this file.

$ sudo vi /etc/apache2/envvars

Look for the line

PATH = ...

Also read : How to Export to CSV in NodeJS

For example, it might be something like

PATH = /usr/local/bin:/usr/bin:/bin

Let us say you want to append /opt/local/bin to the PATH variable.

Also read : How to Make POST request in cURL

You can add :/opt/local/bin to the above PATH variable

PATH = /usr/local/bin:/usr/bin:/bin:/opt/local/bin

OR add the following line to /etc/apache2/envvars file.

export PATH=$PATH:/opt/local/bin

Save and close the file.

Restart Apache server to apply changes.

$ sudo service apache2 restart

That’s it. Your Apache server’s environment variable will be updated.

Also read : How to Disable HTTP Strict Transport Security Protocol in Apache

Leave a Reply

Your email address will not be published. Required fields are marked *