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
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
Pitfalls to watch out for
- 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
- Run
sudo apt install apache2on Ubuntu (or WSL). - Open
http://localhostin your browser and confirm the default page. - Replace
/var/www/html/index.htmlwith your own HTML and test the display.
Summary
Check The first step of a web server is?