How to install Apache Tomcat on Windows
Tomcat is an open-source Java application server provided by Apache, it is the most popular application server for the java environment. In this article, we provide a step-by-step guide on how to install and set up an apache tomcat in a windows environment.
Tomcat doesn’t work without Java, so before installing tomcat on the machine, you should install a compatible Java runtime version and set up the JAVA_HOME environment variable. Both java and tomcat versions should be compatible so I recommend always install the same version for java and tomcat, in this tutorial we use java 8 and tomcat 8.
2. Installation Steps
There are two ways for installing tomcat in a windows machine, you can either install it as a windows service or as a standalone application.
2.1 Install Tomcat as a windows service
The main benefit of installing Tomcat as a windows service is to allow starting it automatically at the startup of the windows.
Following are the steps for installing and setting up tomcat as a windows service:
- Download the windows service installer from here.
- Install the downloaded file, pass all the setup until reaching Configuration Options. here you can set the service name, the shutdown port, and the running port of tomcat, by default tomcat runs on port 8080, so I recommend keeping the default configuration as it is, you can always change this configuration after the installation.
- After completing the installation, the tomcat folder can be found under “C:\Program Files\Apache Software Foundation\Tomcat 8.5”.
- If you open the windows services, you find a new service called Apache Tomcat 8.5 Tomcat8, change its startup type to Automatic.
And here you go, tomcat is installed as a windows service, and will start at the windows startup.
2.2 Install Tomcat as a standalone application:
If you want to manage the startup of tomcat manually, you can install it as a standalone application through the following steps:
- Download the tomcat zip file from here.
- Extract the downloaded zip under the “D:” drive.
- To start tomcat, run “startup.bat” file under “D:\apache-tomcat-7.0.35\bin”.
- To stop tomcat, run “shutdown.bat” file under “D:\apache-tomcat-7.0.35\bin”.
3. Change the default port of Tomcat
To change the default running port of tomcat, open “server.xml” under the “D:\apache-tomcat-7.0.35\conf” folder and change the port attribute of the Connector tag.
<Connector port="9095" protocol="HTTP/1.1"
Here, we set tomcat to run on port 9095, a restart is required for the change to take effect.
4. Check if Tomcat is up
In order to make sure that tomcat is started up correctly on the configured port, just run localhost:9095 URL on any browser and if you get the following screen then tomcat is up and ready to serve requests.
4. Tomcat Logging
Tomcat log files can be found under “D:\apache-tomcat-7.0.35\logs”, there are 2 important log files to be checked when investigating applications issues:
- tomcat8-stderr.<date>.log: This file logs all the runtime exceptions which are thrown by the running application.
- tomcat8-stdout.<date>.log: This file displays all the trace and info logs generated by the application.
If these files are not found, you can check the catalina.<date>.log file which holds all the exceptions and info logs generated by the application.