Step-by-step guide for installing tomcat on windows
Tomcat is an open source java application server provided by Apache, it is the most popular application server for java environment. In this article we provide a step-by-step guide for installing and setting up tomcat in windows environment, for those who are interested in unix machines you can refer to this guide.
Tomcat doesn’t work without java, so before installing tomcat on the machine, you should install a compatible java runtime version and setup JAVA_HOME environment variable. Both java and tomcat versions should be compatible so i recommend to always install the same version for java and tomcat, in this tutorial we use java 8 and tomcat 8.
Follow this tutorial to setup java on your windows machine.
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.
Tomcat as a windows service:
The main benefit for 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 to keep the default configuration as it is, you can always change these 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.
Tomcat as a standalone application:
If you want to manage manually the startup of tomcat, you can install it as a standalone application through the following steps:
- Download the tomcat zip file from here.
- Extract the downloaded zip under “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”.
To change the default running port of tomcat, open “server.xml” under “D:\apache-tomcat-7.0.35\conf” folder and change the port attribute of 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.
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.
OR if these files are not found, you can check catalina.<date>.log which holds all the exceptions and info logs generated by the application.