Intro to Building a Web Server on Linux

"Publishing my own website for the world to see" is one of the best motivations learning Linux. Install a web server program like Apache or nginx on Ubuntu, put an HTML file in the right folder, and your browser can display it immediately. This article walks through the entire process.

What exactly is a web server?

A web server is software that receives requests from a browser ("show me this page") and returns the corresponding HTML files and images. The two main examples are Apache and nginx (pronounced "engine-x"). Both are free OSS tools you can install on Ubuntu with a single command. Rather than worrying about which is faster at first, focus on experiencing the basic flow: receive a request, return a file.

How a web server works

Actual Apache setup flow (done in 5 minutes) Just 3 commands in Ubuntu and your own web server is running $ sudo apt update ↑ Refresh package info (30 seconds) $ sudo apt install apache2 Reading package lists... Done apache2 is now started. ↑ Install Apache and start it (30 seconds) $ curl http://localhost <!DOCTYPE html><html> <h1>Apache2 Default Page: It works!</h1> ↑ Default page returned = Apache is running $ sudo nano /var/www/html/index.html ↑ Replace with your own HTML → refresh browser to see it instantly Total time: ~5 minutes. Extra cost: zero.
Fig 1: 3 commands and your own web server is live. Put HTML in /var/www/html/ and it's instantly served.

Steps to install and run Apache

Setting it up on Ubuntu is surprisingly simple. Run these three things in the terminal and your web server is running.

sudo apt update (refresh package info) → sudo apt install apache2 (install Apache) → open http://localhost in your browser. If you see a page that says "Apache2 Default Page," you succeeded.

To replace it with your own page, edit /var/www/html/index.html. Open it with sudo nano /var/www/html/index.html, rewrite the HTML, save, and refresh your browser. The change appears instantly.

localhost is a special name that means "this computer itself." At this stage you're not publishing to the world — the web server is just running inside your own PC. Start safely with local testing, understand how it works, then move to a cloud instance or VPS to go public.

How Apache and nginx differ

nginx is known for handling many simultaneous connections more efficiently than Apache. The configuration file syntax is different, but they can do roughly the same things. Recent cloud services increasingly use nginx. A natural path is to start with Apache, get comfortable, then explore nginx.

In practice, a web server doesn't work alone — it's combined with PHP or Node.js, a database, an SSL certificate, and a firewall. Apache and nginx act as the front door, passing requests through to the application behind them. For learning, displaying an HTML page is enough, but beyond that you'll find log analysis, error investigation, enabling HTTPS, and access control waiting to be explored.

What opens up with a web server

Apache vs Nginx: Features and Performance Teens should start with Apache, then move to Nginx when ready Characteristics Best for Apache HTTP Server (since 1995) Rich config options, modular design, tons of tutorials available Lots of learning resources Education / small-to-medium sites Nginx (since 2004) Async I/O handles many connections, simple config, low memory High-speed, large-scale Major web services Web Server Learning Path ① Local localhost display → ② Home LAN Family devices view → ③ Free cloud tier World can access → ④ Custom domain Get a .com
Fig 2: Start at ① localhost, end at ④ your own domain — that's the pro starting line.

Pitfalls to watch out for

Things to keep in mind when publishing a web server
  • Don't expose your home PC directly to the internet. Start with a cloud free tier or shared hosting instead.
  • Never put files containing personal info or passwords in /var/www/html/ — it's publicly accessible.
  • HTTPS (SSL certificate) is a must. Let's Encrypt lets you set it up for free.

How will this help your future?

Experience building and operating a web server is foundational for web engineers and infrastructure engineers. Having touched Apache or nginx means you can concretely explain where a website runs and how it reaches a browser. As a teen who can say "I ran my site on a Linux server," you'll stand out in college counseling sessions and internship applications.

Things you can do today

Get started in 3 steps
  1. Run sudo apt install apache2 on Ubuntu (or WSL).
  2. Open http://localhost in your browser and confirm the default page.
  3. Replace /var/www/html/index.html with your own HTML and test the display.

Summary

Building a web server on Linux is a simple three-step process: choose Apache or nginx, install it, and put your HTML in place. Start with localhost, then when comfortable move to a cloud free tier to go public. Watch your public folder and set up HTTPS — and you'll have the experience of sharing your site with the world.

Check The first step of a web server is?