How to Set Up a Local Ubuntu Server(22.04) on VMware for Web App Testing
Tags: linux, ubuntu, webdev, javascript
Published: 2024-04-23 19:02:03

I usually code on my Windows machine because it's cozy and convenient 😊. But for launching my projects, I use a Linux server. I thought about getting a second server for testing new ideas. Then, a great idea struck! 🌟 Why not use a virtual machine on my current setup? It's like having a small test lab without needing extra hardware.

I prefer using VMWare 🖥️ to create virtual machines, and I install Ubuntu on them. You can find VMWare [here](https://www.vmware.com/products/workstation-player.html "VMWARE"). Also, make sure to grab an ISO of the latest Ubuntu server version, which is currently 22.04.4. You can download it [here](https://ubuntu.com/download/server "ubuntu server 22.04.4"). This setup helps me ensure that my digital sandbox is always ready for action! 🚀

**System Requirements:** (As Official Ubuntu Page Suggests)

![Image description](https://eneaslari.com/b9ed62bc-74f4-45eb-b6eb-00206bee0ef1.PNG)

Now Lets Create the Virtual machine at VMware

1. 🎉 **Kick things off by creating a new Virtual Machine!** 🎉

   ![Image description](https://eneaslari.com/a80aa617-73c0-421b-bbf1-272a68dc89ba.PNG)

   Click that big shiny “Create a New Virtual Machine” button and feel like a boss! 🚀

2. 📀 **Now, grab that ISO you snagged from Ubuntu!** 📀

   ![Image description](https://eneaslari.com/6f9ce5f7-2b66-4890-820d-85eead026d68.PNG)

   Time to pick the ISO file you downloaded earlier. It’s like choosing the perfect topping for your ice cream! 🍦

3. 🖊️ **Time to name your new digital baby and pick its home!** 🖊️

   ![Image description](https://eneaslari.com/87f2939e-86db-4ff6-8533-69bdda120bf0.PNG)

   What’s in a name? Everything! Name your VM and choose where it's going to live on your computer. Like setting up a room for a new pet! 🐾

4. 💾 **How much space will your VM need? Pack its digital suitcase!** 💾

   ![Image description](https://eneaslari.com/8d505718-b2f8-4b61-ac9a-a076a501dac4.PNG)

   Slide that bar to give your VM room to stretch its legs. More GBs, more fun! 🎢

5. 🎬 **Hit 'Finish' and let the magic happen!** 🎬

   ![Image description](https://eneaslari.com/67d380b8-fe41-49f8-b085-63dbad7dc910.PNG)

   All set? Smash that Finish button like you’re launching a rocket to Mars! 🚀🌌


**Now Lets Install Ubuntu 22.04 LTS Server Edition**

🚀 **Step 1 - Let's Get This Boot-y Party Started with Ubuntu ISO!** 🚀

Plug in that shiny new Ubuntu 22.04 bootable USB drive you prepared. Time to wake up your system with a jolt of Ubuntu energy! ⚡️

When your system starts, you'll be greeted by the Grub menu, like a doorman at a fancy club. By default, it’s all set to take you straight to the "Try or Install Ubuntu Server" option—like the VIP entrance! 🌟

Just sit back and let it whisk you away into the live system, no clicks needed. It’s like your computer is on autopilot! 🛫

 ![Image description](https://eneaslari.com/b1176ab6-c6e7-48c3-a646-fa6baa3e8cca.png)


🌍 **Step 2 - Pick Your Linguistic Adventure for the Ubuntu Installer!** 🌍

After a short techno intermission (just a few seconds!), you'll dive into the language selection window. It's like choosing the language for your epic adventure in the Ubuntu world! 🗺️

I go with "English" because it's classic and straightforward, like ordering vanilla at an ice cream shop—but hey, vanilla goes with everything! 🍦

Press ENTER and stride confidently into the next phase. It’s like hitting the "Next" button on your journey to tech greatness! ⭐️

![Image description](https://eneaslari.com/de63ac43-0946-40e1-9bd6-4a138d7eec0f.png)

Step 3 - Keyboard Configuration
Choose your preferred keyboard layout. I go with English US.

![Image description](https://eneaslari.com/752221a6-0d05-4dc5-a19f-3aaad1363903.png)

🛠️ **Step 4 - Select Your Ubuntu Installation Flavor!** 🛠️

Time to lay the foundation! You’ll see two savory options pop up:

- **Ubuntu Server:** The classic choice, packed with all the essentials for a robust server. It’s like the full meal deal!
- **Ubuntu Server (minimized):** Stripped down for speed, perfect for systems where human logins are as rare as a unicorn sighting! 🦄

I stick with the hearty standard: **Ubuntu Server**. Just hit enter and keep cruising on your setup journey! 🚀

![Image description](https://eneaslari.com/edf7ed16-50b8-4230-975e-73fc166f10fd.png)


🌐 **Step 5 - Hook Up Those Network Connections!** 🌐

Now, let's get your server chatting! It’s time to configure at least one network interface to make sure your server can mingle with other systems. 🤝

Got a DHCP server on your network? Great! By default, your server is set to automatically snag an IP address from the DHCP server—like getting a free pass to the internet party! 🎫

Just leave it as is to continue seamlessly. Your server is about to get connected without lifting a finger! 🎉


![Image description](https://eneaslari.com/74cbfb32-4f34-4b89-af7d-23a0ca588d0c.png)

🔗 **Step 6 - Configure Proxy** 🔗

Need a proxy to access the internet? Enter the details now. If not, just leave it blank and hit ENTER to continue. 🚀

![Image description](https://eneaslari.com/da06bc2c-8e56-42aa-b815-2c296f242629.png)

📡 **Step 7 - Choose Your Ubuntu Archive Mirror** 📡

The installer automatically selects the nearest archive mirror for your server. If you prefer a different one, just enter your chosen mirror's details. Otherwise, you're all set to go with the default!


![Image description](https://eneaslari.com/6c3c1ef6-cf57-4fd0-824b-6753f7492ba2.png)

**Step 8 - Update Installer (Optional)**

You might get a prompt about a new Ubuntu installer update. Fancy the latest features? Choose "Update to the new installer" and hit ENTER. It’ll download and refresh your setup process.

Prefer to keep things classic? Select "Continue without updating". 

I'm going for the update to check out the new installer TUI! 🔄

![Image description](https://eneaslari.com/e63a7046-6fda-4a5f-a210-8a137c39ae8c.png)

**Step 9 - Disk Partitioning**

Time to decide on disk space! Let the installer automatically partition your drive or customize it manually. Choose what suits your setup best!

If you want to automatically partition the disk, simply choose "Use an entire disk" option.(I will choose this because I have a virtual machine)

![Image description](https://eneaslari.com/8e153b7a-8e96-47b4-b184-4b6f5f9ffc88.png)

**Step 10 - Set Hostname and User Details**

Now, name your Ubuntu server (hostname) and set up your username and password. These details will be your keys to logging in later!

![Image description](https://eneaslari.com/8bae0294-030f-44ca-81c9-c71af2c4960d.png)

**Step 11 - Enable Ubuntu Pro**

If you have an Ubuntu Pro account, select "Enable Ubuntu Pro" to upgrade your server. This ensures security updates until 2032.

![Image description](https://eneaslari.com/8a3a52aa-0f0e-4172-8f4b-add5620ba0e4.png)

**Step 12 - Configure SSH**

In step, you can setup SSH. Check the "Install OpenSSH Server" check-box and choose "Done" and hit ENTER

![Image description](https://eneaslari.com/3fcf2ae6-fa10-47a4-afcb-45b32ba02eb0.png)

**Step 13 - Select Featured Server Snaps**

Next up, choose from popular snap applications to install on your server. Use the SPACEBAR to select or deselect your preferred apps, then hit ENTER to continue.

![Image description](https://eneaslari.com/1b23ac9d-312d-4dec-adeb-138cc8e139bb.png)

**Installation Begins**

Your Ubuntu server installation is now underway! It's downloading and installing numerous packages, so grab a coffee and hang tight—it'll be worth the wait! ☕🕒


![Image description](https://eneaslari.com/2607360a-d0d1-4f80-986d-88a69218d8e4.png)

**Step 14 - Reboot Ubuntu Server**

After the installation wraps up, choose "Reboot Now" and press ENTER to restart your Ubuntu server and bring all the changes to life!

![Image description](https://eneaslari.com/b9de8518-c97e-4ebd-9105-afabcd6d0bf3.png)

**Congratulations!** 🎉 Ubuntu 22.04 LTS server is successfully installed! You're all set to start using your new server. Great job!

**Log in to Ubuntu Server**

Time to dive in! Log in to your newly installed Ubuntu server using the username and password you set up during the installation. You’re ready to start exploring your new server environment! 🚀

![Image description](https://eneaslari.com/2c2ae8f2-c276-4352-b79e-dc6af25bd423.png)

**Update Ubuntu**

Right after installation, it's crucial to get the latest updates. For Ubuntu, fire up your terminal and run these commands to ensure everything is up-to-date:

1. To fetch the list of available updates:
   ```bash
   sudo apt update
   ```
2. To upgrade all your packages to the latest versions:
   ```bash
   sudo apt full-upgrade
   ```

This will keep your server secure and running smoothly.

![Image description](https://eneaslari.com/b15c24b3-2b4b-4792-978a-013eefa1205f.png)

During the installing updates task, you will be prompted to restart some services. Choose OK to do so.

![Image description](https://eneaslari.com/09645010-3ecf-450b-adb8-e512e51f6438.png)

**Clean Up and Reboot**

After updating, it's good practice to clean up any unnecessary files or packages. Here's how you can tidy up your Ubuntu server:

1. Remove packages that are no longer required:
   ```bash
   sudo apt autoremove
   ```
2. Clean up the local repository of retrieved package files:
   ```bash
   sudo apt autoclean
   ```

Once that's done, give your system a fresh start with a reboot:

```bash
sudo reboot
```

This ensures your server is lean, clean, and up to date!

To utilize the Linux server now ready on VMware, you can directly access it, but for those who prefer a visual directory structure for file editing, Visual Studio Code is a great option. You can connect to the server via SSH through Visual Studio Code. It's important to note that the virtual machine must remain running for the duration of your connection session with Visual Studio Code. Here's how to set this up for a more efficient workflow.

Let's connect to our VPS with visual studio Code

**Step 1 — Install the Remote-SSH Plugin**

Search Remote-SSH on extensions Marketplace and install it

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vbxk74zjfjan807evtnm.png)

**Step 2 — Configuring the Remote-SSH Plugin and Connecting To Your Server**

Now that you have the plugin installed you can configure it to connect to a server. To do so, you’ll need the following pieces of information:

The server’s IP or hostname.

- The server’s IP or hostname.

- The username you’ll connect with.

- The private key you’ll use to authenticate your user.

You’ll use this information to create an SSH configuration file that Visual Studio Code can use to SSH to the server to sync files and execute code on your behalf. You will create this configuration using Visual Studio Code.

Now that you have the Remote-SSH plugin installed, you’ll see a small green box in the bottom left-hand corner of the Visual Studio Code interface.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7xecr6r1fqkzat3iqda.png)

Click the button, and a dialog box appears in the top center. Select Remote-SSH: Open Configuration File… from the list:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v38mc6dmxsv95wb8uy37.png)

The next prompt will ask you which configuration file you want to open. If you’re on Windows, you’ll see two locations: one in your personal user directory, and one in the installation location for SSH. You should use the file in your user directory when configuring the server.

Select the file and your editor will open the config file. Add the following code to the file to define the connection to your server, replacing the highlighted sections with the information for your server:

```bash
Host my_remote_server
    HostName your_server_ip_or_hostname
    User sammy
    IdentityFile /location/of/your/private/key
```
Visual Studio Code is now configured and ready to connect to your server. Click on the green Open a remote window button in the bottom left-hand corner and select Remote-SSH: Connect to Host…

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9qdadrz18nm55ihu0nlt.png)

Once you’ve done this all the available and configured servers will appear in the dropdown menu. Select the server that you want to connect to from this list.

If this is the first time you have connected to this server from your machine, you’ll likely be prompted with the SSH Fingerprint verification dialog, like the one in the following image:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyzqd1lyhkbh69m5jzqz.png)
This is to ensure that you are really connecting to the server you think you are. You can verify this by logging in to your server manually and running ssh-keygen -l -f /etc/ssh/ssh_host_key.pub to view the fingerprint of the server. If this fingerprint is the same as the one being presented to you in Visual Studio Code, then you are indeed connecting to the server you think you are so you can click Continue.

Visual Studio Code defaults to opening a new window when a new connection is made. A new window will appear with the welcome screen. You’ll know that your connection was successful if you see SSH: your_ip_address_or_hostname in the green box in the bottom left-hand corner. This means that Visual Studio Code is connected and communicating with your remote server.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u4d7w430b5ke83hii80u.png)

Next let's clean and update the server

Run the following commands

```bash
apt clean all && sudo apt update && sudo apt dist-upgrade
```

```bash
rm -rf /var/www/html
```

**Nginx**

Nginx, pronounced like “engine-ex”, is an open-source web server that, since its initial success as a web server, is now also used as a reverse proxy, HTTP cache, and load balancer.

**Installing Nginx**

```bash
apt install nginx
```

**UFW**

Uncomplicated Firewall (UFW) is a program for managing a netfilter firewall designed to be easy to use. It uses a command-line interface consisting of a small number of simple commands, and uses iptables for configuration. UFW is available by default in all Ubuntu installations since 8.04 LTS.[1] UFW has been available by default in all Debian installations since 10.

Install ufw

```bash
apt install ufw
ufw enable
```

Give nginx full control of firewall

```bash
ufw enable
```
Now you have a full configured ubuntu server. You can run Node.js, dotNet core, static websites , database servers and many other things  into your machine

Tell me if you want to to make a new post on how to run some of them in your server.

Thanks for your time.
Leave a question or comment below.