Home > Article > Web Front-end > How to configure environment variables in tomcat
You need to create an environment variable: TOMCAT_HOME, pointing to the Tomcat installation directory. Add ${TOMCAT_HOME}/bin to the PATH variable to allow global use of Tomcat commands. Refresh environment variables (optional) to take effect immediately.
How to configure Tomcat environment variables
1. Create TOMCAT_HOME
Create a new system variable in the system named TOMCAT_HOME, and set its value to the path of the Tomcat installation directory.
2. Edit PATH
Add %TOMCAT_HOME%\bin to the PATH environment variable. This will allow you to use Tomcat commands from anywhere.
3. Refresh environment variables (optional)
For some systems, you may need to refresh the environment variables so that they take effect immediately.
Windows
At the command prompt, type the following command:
<code>setx /M PATH "%PATH%;%TOMCAT_HOME%\bin"</code>
macOS and Linux
#In Terminal, type the following command:
<code>export PATH=$PATH:/PATH/TO/TOMCAT/HOME/bin</code>
Alternatively, you can add the following line to your .bash_profile or .profile file:
<code>export PATH=$PATH:/PATH/TO/TOMCAT/HOME/bin</code>
Then, reload the profile:
<code>source ~/.bash_profile</code>
Example
On Windows, if Tomcat is installed in C:\Program Files\Apache Software Foundation\Tomcat 9.0, the configuration is as follows:
After completing these steps, you will Ability to use Tomcat commands from any location, such as starting, stopping, and reloading the server.
The above is the detailed content of How to configure environment variables in tomcat. For more information, please follow other related articles on the PHP Chinese website!