How to Set Up Apache Tomcat on a Virtual Machine Using Hyper-V on Windows 11 Pro

Jimin
5 min readMar 8, 2024

--

Creating a development or test environment using virtual machines (VMs) offers flexibility and isolation, making it an ideal choice for exeprimenting with different server setups like Apache Tomcat. This guide will walk you through setting up Apache Tomcat on a virtual machine using Hyper-V on Windows 11 Pro.

Step 1: Enable Hyper-V

  1. Open Windows Features: Press Windows + S to open the search bar, type “Turn Windows features on or off”, and press Enter.
  2. Enable Hyper-V: In the Windows Features window, scroll to find “Hyper-V” and check the box next to it. Click “OK” and restart your computer if prompted.
Step 1–2

Step 2: Create a New Virtual Switch

  1. Open Hyper-V Manger: Search for it in the Start menu and open it.
  2. Select Your Host Machine: In the left pane of Hyper-V Manager, you’ll see your host machine listed under “Hyper-V Manager.” Click on it to select it.
  3. Access Virtual Switch Manager: In the Actions panel on the right, click on “Virtual Switch Manager.”
  4. Create Switch: Select “New virtual network switch,” choose “External,” and click “Create Virtual Switch.” Name your switch, select the external network you’re connected to for internet access, and click “OK.”
Step 2–2, 3
Step 2–4 (1)
Step 2–4 (2)

Step 3: Set Up a New Virtual Machine

  1. New Virtual Machine Wizard: Back in Hyper-V Manager, click “New” > “Virtual Machine” on the right panel to launch the wizard. Click “Next” to start.
  2. Specify Name and Location: Name your VM (e.g., “TomcatServer”) and choose its location. Click “Next.”
  3. Specify Generation: Choose “Generation 1” for broader compatibility. Click “Next.”
  4. Assign Memory: Allocate at least 2048 MB of memory and check “Use Dynamic Memory.” Click “Next.”
  5. Configure Networking: Select the virtual switch you created earlier. Click “Next.”
  6. Connect Virtual Hard Disk: Set the size for your VM (e.g., 25GB). Click “Next.”
  7. Installation Options: Choose “Install an operating system from a bootable image file,” then click “Browse” to select your downloaded Linux ISO file. For a Linux-based operating system, especially if you’re new to virtualization or Linux, I recommend using Ubuntu Server as the image file for installation. Ubuntu Server is widely used, well-documented, and beginner-friendly, making it a good choice for learning and experimentation purposes. Click “Next,” then “Finish.”
Step 3–1
Step 3–2
Step 3–3
Step 3–4
Step 3–5
Step 3–6
Step 3–7

Recommended Ubuntu Server Installation

  1. Download Ubuntu Server ISO:
    - Go to Ubuntu Server download page.
    - Click the button “Download Ubuntu Server [version number] LTS” (version number could be changed).
  2. Install Ubuntu Server: (Step 3–7 above)
    - Choose “Install an operating system from a bootable image file” in your virtualization software.
    - Click “Browse” and select the downloaded Ubuntu Server ISO file.
    Follow the prompts to complete the installation.
Download Ubuntu Server LTS

Step 4: Install the Operating System

  1. Start the VM: Right-click your new VM in Hyper-V Manager and click Connect,” which opens a new window. Then, click “Start” and proceed through the OS installation process within the VM.
  2. Install OS: Follow the on-screen instructions to complete the installation of your chosen operating system.

Step 5: Install Apache Tomcat

Once Linux is installed and your VM is running:

  1. Open Terminal: Log into your Linux system and open a terminal window.
  2. Update Package List: Update your package manager’s list by running:
sudo apt update

3. Install Java JDK: Apache Tomcat requires Java. Install the default JDK package by running:

sudo apt install default-jdk

4. Download Apache Tomcat: Visit the Apache Tomcat website to find the download link for the latest version, or download it directly via the terminal using wget. You can find the URL for the tar.gz file for the version you want to install on the Tomcat Downloads page.

wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.19/bin/apache-tomcat-10.1.19.tar.gz

(Make sure to replace the URL with the latest version’s URL.)

5. Extract and Install Tomcat: Extract the Tomcat archive to your desired directory, for example, /opt/tomcat.

sudo mkdir /opt/tomcat 
sudo tar xvf apache-tomcat-*tar.gz -C /opt/tomcat --strip-components=1

6. Set Permissions: Change directory to your Tomcat installation and set the appropriate permissions: Since these actions require elevated privileges, begin by opening a new shell with root access using sudo -s. After you’re done, exit the root shell by typing exit.

sudo -s
cd /opt/tomcat/bin
chmod +x *.sh
exit

Step 6: Start Apache Tomcat

  1. Start Tomcat: From within your Tomcat directory, start Tomcat by running:
sudo /opt/tomcat/bin/startup.sh

2. Verify Tomcat Status: Once Tomcat is running, execute the following curl command to check if the server is responsive:

curl -I http://localhost:8080

This command sends an HTTP HEAD request to the Tomcat server running on port 8080 and displays the response headers. A successful response indicates that Tomcat is running properly.

Congratulations! You’ve successfully set up a virtual machine using Hyper-V on Windows 11 Pro, installed an operating system, and got Apache Tomcat running on it. This VM setup provides an isolated environment to experiment with Tomcat and develop Java web applications without affecting your main operating system.

--

--

Jimin
Jimin

Written by Jimin

DevOps engineer and tech enthusiast. Sharing tech insights to simplify the complex. Let's connect on LinkedIn! https://www.linkedin.com/in/byun-jimin/

No responses yet