Start the Tomcat Web Server
Which command do I execute on a Linux system to determine the version of Tomcat running?
There are two ways to determine the version of Tomcat running on a Linux system.
Method 1:
- Open a terminal window.
- Navigate to the Tomcat bin directory.
- Run the following command:
sh version.sh
Another way of determining which version of Tomcat is running is by entering the command:
[root@ip-222-32-8-123 ROOT]# find / -type f -name version.sh
The following is the output of the above command.
/opt/apache-tomcat-10.0.23/bin/version.sh
Starting the Tomcat Web Server
Describe the process of starting the Tomcat Web Server for apache-tomcat-10.0
- Download and Install the Apache Tomcat server: The Apache Tomcat server is open-source and free. You can download the latest version from the Apache Tomcat's official website. Select the right version for your operating system. After downloading, extract the files to your preferred location. The folder that gets extracted is referred to as CATALINA_HOME.
- Set JAVA_HOME Environment Variable: Apache Tomcat requires Java to run, so you'll need to have the Java Development Kit (JDK) installed on your machine. You can download this from the official Oracle website. After installing JDK, set the JAVA_HOME environment variable to point to the installation directory of your JDK. The process to do this differs between operating systems.
- Configure Tomcat Users: If you want to access the Tomcat Web Application Manager and other administrative functions,
you'll need to add a user with appropriate roles. This can be done in the tomcat-users.xml file located in the conf directory within CATALINA_HOME. Below is an example of a user with admin privileges:
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="admin" password="password" roles="manager-gui,admin-gui"/>
</tomcat-users>
Replace "password" with a secure password of your choosing.
- Start Apache Tomcat: Now that Tomcat and Java are installed and configured, you can start the Apache Tomcat server. The process differs between operating systems:
- On Windows: Navigate to the bin directory within CATALINA_HOME in your command prompt and execute the startup.bat file by typing startup.bat and pressing Enter.
- On Linux/MacOS: Open a terminal, navigate to the bin directory within CATALINA_HOME, and execute the startup.sh file by typing ./startup.sh and pressing Enter.
- Verify Tomcat is Running: To verify that Tomcat is running, open a web browser and navigate to http://localhost:8080. If Tomcat has started successfully, you should see the Apache Tomcat home page.
Remember to replace the path placeholders (CATALINA_HOME) with your specific paths. Also, Tomcat's default port is 8080. If this port is in use on your machine by another service, you'll need to change the port number in the server.xml file in the conf directory.
Additionally, while this guide provides a basic setup process, there are many other configuration options available in Apache Tomcat, including setting up HTTPS, adjusting logging levels, and many more. These are not covered in this guide but are worth exploring as you become more familiar with running a Tomcat server.
Remember that before you can be served a page from the Java Web Server, it must be started.
Open an MS-DOS prompt and change to the folder where you installed the server C:\JWS
on my system.
Then change to that folders bin
directory and enter this command
httpd
Do not close this MS-DOS prompt, or sign off and sign on as another user, until you have shut down the server from the administration page, by opening
http://localhost:9090
in a browser and shutting down the server.
You will leave your system unstable if you close the DOS prompt or sign off while the server is still running.