I have an RHEL server with tomcat installed. Tomcat runs as a no-login user called tomcat . I have set the required environment variables in /etc/profile.d/myenvvars.sh
as
export JRE_HOME=/usr/lib/jvm/jre
export MY_VAR=/usr/share/mydir
The environment variables are set and can be echoed in the terminal using
# echo $MY_VAR
# sudo -u tomcat echo $MY_VAR
However when tomcat starts my environment variable is not recognised by tomcat.
As per this article I found that my environment variables will not be recognised when tomcat starts as tomcat is a no-login user. Therefore I sourced the above file in ~/.bash_profile
using
. /etc/profile.d/myenvvars.sh
However, I still have the same issue, the environment variable is not reccognised.
Any help would be appreciated.
As stated in the article your linked your settings need to be in ~/.bashrc
.
There may be a chance that even this is not working... depending on how your tomcat is started.
You could have a custom script for tomcat to make sure it loads the environment variables e.g. something like this
tomcat-start.sh
. /etc/profile.d/myenvvars.sh
tomcat
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With