Set environment variable in script / access shell in Tomcat application

I want to add an environment variable that can access my tomcat web application. I went through this link , but I want to set the environment variable for the root user. How to do it?

+6
source share
3 answers

got the solution ... what I did, I put the export instructions in /etc/init.d/tomcat6 at the top and restarted the server with the sudo /etc/init.d/tomcat6 restart command. So, now my web application running on the tomcat server can access this variable.

0
source

According to the docs ( http://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt ) you should set all env vars to $ CATALINA_HOME / bin / setenv.sh

EDIT: For completeness, I think it's worth mentioning that, although this is the recommended way, the docs state that:

By default, the setenv script file is missing. If the script file is provided in both CATALINA_BASE and CATALINA_HOME, CATALINA_BASE is preferred.

If it is missing, you can also search for env vars in:

  • /etc/tomcat/tomcat[67].conf (suse) or
  • /etc/default/tomcat[67].conf (e.g. ubuntu) or
  • /etc/sysconfig/tomcat[67].conf (rhel, fedora)
+5
source

Does this work?

Go to the environment file. sudo vi / etc / environment and Add the required variable. and save the file.

I think in recent Ubuntu you will need to reboot the system for the changes to take effect.

-1
source

Source: https://habr.com/ru/post/913191/


All Articles