Most computers come with their own web server and, if they don’t, it’s easy to install one. Setting it up can take a bit of work, but it’s well worth it in my opinion. In fact, I don’t consider my computer set up until I can visit localhost in a browser.
What Is a Local Web Server?
Behind every website is a web server. This term can refer to both software and hardware: the program that listens for URL requests and serves documents in return, and the computer on which it runs.
In this context, I’m talking about the software—like Apache or nginx—which you can set up on your own desktop computer. That machine will then act as a web server.
Setting up a local web server doesn’t necessarily mean it’s open to the internet, for anyone in the world to view. In fact, I recommend against that. Although you can host a public web server from your home, you should probably only do so as a temporary experiment, for security and cost reasons. But a local web server that only you can view is another story.
With a local web server set up, you can view your own files in a web browser, usually by visiting Typically, this will show a “welcome” page, although you may need to install and set up your web browser, depending on the OS you’re using.
How to Install and Configure a Web Server
If you’re running Windows, Internet Information Services should already be available, you just need to turn it on. You may find this web server works fine for your purposes, but it’s a proprietary product and is not as commonly used as Apache.
Apache remains the most well-known and available web server across all operating systems. It’s very easy to install and get started, although it’s also a highly configurable program, and it can be complicated if you want to try out anything beyond the basics. Apache is installed by default on macOS, and it may even be running automatically without you knowing it—just check to see.
If Apache isn’t already running on macOS, try running sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist.
Nginx is a great alternative and, like Apache, is free and open source. If you’re running a Linux distro that doesn’t already come with Apache, it’s probably worth installing Nginx for a slightly nicer first experience.
sudo apt install nginx
Whichever web server you install, you’ll need to set a document root. This is the top-level directory of your server, and—by default—you’ll only be able to view files below this directory via The default Apache location on macOS is /Library/WebServer/Documents, while /var/www/html is typical on Linux, for both Apache and nginx. The specific location may vary depending on your distribution.

Related
Apache vs. Nginx: Which Web Server Is the Better Choice?
Nginx and Apache combined serve over 50% of the web.
To check the document root, search for the relevant setting in the configuration file for your web server. For Apache on macOS, this should be in /etc/apache2/httpd.conf:
DocumentRoot "/Library/WebServer/Documents"
On Linux, you may find the config file at /etc/apache2/sites-enabled/000-default.conf. For nginx, it should be at /etc/nginx/sites-enabled/default and the directive will look something like this:
root /var/www/html;
If you want to set up a site in the default location, that’s fine, but I like to set aside a directory in my home and serve files from there instead.
What Can You Use It For?
A local web server is perfect for local websites, but it can do a lot more besides.
Browsing Parts of Your File System
With just a small amount of setup, you can use your web browser a bit like a file manager. It will be read-only, so you won’t be able to use it for file management like renaming or deleting. But you will be able to navigate through directories, view the lists of files inside them, and open those files:
Apache’s autoindex module generates directory indexes when you request a URL that maps to a directory. This is a bit like running ls directory on the command line, although the output is slightly more interactive.
I have a folder on my hard drive that contains most of my work, writing, scraps of notes, images, and so on. By putting a web server in front of it, I can browse through these files whenever I’m in a web browser—which is most of the time. I find that having an instantly-available view of all my personal content comes in handy time and time again.
The default view looks very old-school, but you can customize it with your own CSS and JavaScript if you know how. I’ve set up a system that suits me, which updates the design a bit, and adds features like hideable columns and a simple search filter:
Reading Documentation and Help Files in HTML or Markdown
When you install software, or download any collection of files, you’ll often end up with some highly useful documentation. This may be in a simple text format, a structured format like Markdown or HTML, or even a PDF. Whichever it is, your browser can handle it, displaying the document without opening up a separate app.
For Markdown, I like to use the Markdown Viewer extension for Chrome, which is as simple as its name implies. This tool presents Markdown documents in an attractive, easy-to-read format, with options to handle emoji, a table of contents, and more.
Web Development and Testing
When you’re developing for the web, a local web server is incredibly useful. Rather than uploading your files to a test server or—worse—just crossing your fingers and putting them all live, a local server lets you view your work in progress, without the hassle. You can even work offline, no internet connection required!
This goes for web design work, for your written content, and for complex programming too, whether it’s in client-side JavaScript or a backend language. If you’re working with the latter, you’ll need to configure your web server to handle it, but this is a relatively straightforward process.
Self-Hosting Web Apps
Many “self-hosted” apps target the local web server audience and some of the most common are for media consumption, like music players or image galleries. This setup is much faster than a cloud-based solution, and you don’t need to spend bandwidth uploading and downloading large files.

Related
How to Set Up a Home Media Server You Can Access From Any Device
You’ve got a lot of choices with media server software and the devices you can use to run it.
Piwigo is an open-source web app for managing photos and other media. You can use its self-hosted release for free, though you’ll need PHP and MySQL as well as a web server.
FreshRSS is a clean, lightweight RSS aggregator. You can try its online demo or download and host the app on a web server running PHP.
Keeping a Library of JavaScript Bookmarklets
You can use your web browser’s bookmarks to extend the functionality of any website, by writing your own JavaScript code or downloading existing scripts. However, once these scripts start getting more complicated, bookmarks can barely contain them.
To make the process more bearable, why not host such scripts on your local server and load them into pages via a browser bookmark? This setup lets you carry out tasks like spellchecking a page, extracting data from it, or changing its style to hide unwanted elements.
Some aspects of self-hosting are falling out of fashion, replaced by docker images or cloud-based services. But hosting your own web server is easy to do, makes for great sysadmin practice, and lets you take charge of exactly what’s running on your computer.
Leave a Comment
Your email address will not be published. Required fields are marked *