Practice Laboratory: Setting Up a Web Application on CentOS 9 Using VirtualBox and PuTTY

Objective

  1. Create a CentOS 9 virtual machine in VirtualBox.
  2. Configure NAT networking with SSH port forwarding.
  3. Connect remotely using PuTTY.
  4. Install Apache, MariaDB, PHP, and Git.
  5. Deploy Linux Dash to /var/www/html.
  6. Create an SSH tunnel so the web application is accessible from http://localhost:8080.

Part 1 – Create the Virtual Machine

  1. Open VirtualBox and create a new VM named CentOS9-WebLab.
  2. Configure the VM with the following settings:
    • Type: Linux
    • Version: Red Hat (64-bit)
    • RAM: 4096 MB
    • CPU: 2 cores
    • Disk: 30 GB dynamically allocated
  3. Attach the CentOS 9 ISO image and perform a Minimal Install.
  4. Create a local user account:
Username: student
Password: password123

Part 2 – Configure NAT Port Forwarding

Open the VM settings in VirtualBox and go to:

Settings → Network → Adapter 1 → NAT → Advanced → Port Forwarding
Name Protocol Host IP Host Port Guest Port
SSH TCP 127.0.0.1 2222 22

Part 3 – Connect Using PuTTY

Field Value
Host Name 127.0.0.1
Port 2222
Connection Type SSH

Part 4 – Install Required Packages

sudo dnf update -y
sudo dnf install -y wget curl vim net-tools
sudo dnf install -y httpd mariadb-server php php-mysqlnd php-cli git

Enable and start the services:

sudo systemctl enable --now httpd
sudo systemctl enable --now mariadb

Part 5 – Configure the Firewall

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

Part 6 – Deploy Linux Dash

sudo rm -rf /var/www/html/*
sudo git clone https://github.com/tariqbuilds/linux-dash.git /var/www/html
sudo chown -R apache:apache /var/www/html
sudo chmod -R 755 /var/www/html
sudo systemctl restart httpd

Part 7 – Create the PuTTY Tunnel

Within PuTTY, navigate to:

Connection → SSH → Tunnels
Field Value
Source Port 8080
Destination 127.0.0.1:80
After selecting Add, the entry should appear as:
L8080 127.0.0.1:80

Part 8 – Access the Web Application

Keep the PuTTY session open. On the Windows host machine, open a web browser and navigate to:

http://localhost:8080

If configured correctly, the Linux Dash monitoring dashboard should appear.

Verification Checklist

Task Expected Result
SSH Port Forwarding Host port 2222 forwards to guest port 22
PuTTY Login Successful remote login
Apache Running systemctl status httpd shows active
MariaDB Running systemctl status mariadb shows active
Linux Dash Installed Files exist in /var/www/html
SSH Tunnel Working http://localhost:8080 loads successfully

Troubleshooting

PuTTY Cannot Connect

sudo systemctl enable --now sshd
sudo systemctl status sshd

Browser Cannot Open localhost:8080

sudo systemctl status httpd
sudo firewall-cmd --list-all

Expected Output

The student should successfully access:

http://localhost:8080

and see the Linux Dash web application running from the CentOS 9 virtual machine through the PuTTY SSH tunnel.