DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
VGSources
Blog

How to Serve and Access an HTML File in /var/www/html

A practical guide to placing HTML in /var/www/html, opening the correct localhost URL, understanding Apache and NGINX path mapping, and troubleshooting common errors.
Length9 min Posted Quest giverVGSources Team

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Place your page under /var/www/html, run a web server configured to use that directory, and open http://localhost/ (or http://127.0.0.1/) in a browser. A file named index.html is the usual homepage; any other file is reached by adding its relative path, such as http://localhost/about.html.

What /var/www/html means

/var/www/html is a directory on the Linux filesystem. It is not a URL and cannot be pasted into a browser address bar as though it were a web address. Apache calls the directory it serves DocumentRoot; NGINX calls it root. When either server is configured with that directory, it translates the path in an HTTP request into a file path below /var/www/html.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For example, a request for http://localhost/about.html maps to /var/www/html/about.html. A request for http://localhost/fish/guppies.html maps to /var/www/html/fish/guppies.html. The host and URL path are what the browser uses; the filesystem path is what the server uses internally.

When a directory is requested without a filename, the server looks for an index file. Apache’s documentation describes the conventional behavior this way: “Typically, a document called index.html will be served when a directory is requested without a file name being specified.” Therefore, http://localhost/ normally opens /var/www/html/index.html, provided that file exists and the active server configuration points at the directory.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Before you begin

  • A Linux system with Apache HTTP Server or NGINX installed and running.
  • Shell access with permission to create or copy files into /var/www/html.
  • An HTML file whose spelling and capitalization you know exactly.
  • A browser running on the same machine for a localhost test, or a hostname/IP address that resolves to the machine for another device.

The procedure below assumes Ubuntu-style service names and the standard web root used by the default configurations. A customized virtual host or server block can point somewhere else, so verify the active configuration if the result does not match the steps.

Put the HTML file in the document root

Use index.html for the homepage

Create or copy the landing page as /var/www/html/index.html. A minimal test page is enough to prove that the server is reading the expected directory:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Local test page</title>
</head>
<body>
  <h1>The local server is working</h1>
</body>
</html>

Save that content at /var/www/html/index.html. If you are copying an existing page, preserve its filename exactly. Linux paths are case-sensitive: Index.html, index.HTML, and index.html are different names.

Serve a page with another filename

A page named about.html belongs directly at /var/www/html/about.html and is opened with http://localhost/about.html. For a subdirectory page, create the matching directory first:

sudo mkdir -p /var/www/html/fish
sudo cp about.html /var/www/html/fish/guppies.html

The resulting URL is http://localhost/fish/guppies.html. The URL path after the host mirrors the path below the document root. Do not include /var/www/html in the browser URL.

Confirm the file really exists

Check the exact path before troubleshooting the server:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
ls -l /var/www/html
ls -l /var/www/html/index.html
ls -l /var/www/html/fish/guppies.html

An ls error means the problem is placement or spelling, not HTTP routing. Correct the filesystem path first.

Run a server that uses the directory

Copying a file into the directory does not make it reachable by itself. A web server must be listening for HTTP requests and must have a matching document-root setting.

Apache

Ubuntu’s default Apache configuration uses /var/www/html as its DocumentRoot. If Apache is installed but not running, start it using the system’s service manager. After changing Apache configuration, restart the service so the new settings are loaded:

sudo systemctl restart apache2

If you changed only the HTML file, a service restart is normally unnecessary; the next request reads the updated file. A restart matters after changing the enabled virtual host, DocumentRoot, directory permissions, or index settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

NGINX

NGINX’s default server configuration can likewise use /var/www/html as its root. After an NGINX configuration change, reload it rather than leaving the old configuration active:

sudo systemctl reload nginx

Reloading applies a valid configuration while allowing the service to continue handling requests. If the reload reports an error, inspect the configuration syntax and correct it before trying again. As with Apache, changing an HTML file alone does not require a reload.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Check that the service is active

If the browser cannot connect at all, check the relevant service state:

sudo systemctl status apache2
sudo systemctl status nginx

Use the command for the server you actually run. Running both servers on the same HTTP port can cause a conflict; determine which service owns the active listener and test that server’s configuration rather than switching between them at random.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Open the correct URL

Homepage request

With /var/www/html/index.html present and the server configured for that directory, open:

http://localhost/

http://127.0.0.1/ is the equivalent loopback address. Both addresses test the local machine, not a public Internet connection.

Named-file request

For a file directly below the root, append its filename:

http://localhost/about.html

For a nested file, append each directory and the filename:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
http://localhost/fish/guppies.html

A trailing slash identifies a directory. If /var/www/html/work/index.html exists, http://localhost/work/ can serve that index file. A URL ending in /work may be redirected or interpreted differently by the server, so use the slash form when you mean a directory.

Testing from another device

localhost always means “this device.” Typing it on a phone points to the phone, not your Ubuntu computer. To test from another machine, use the serving computer’s hostname or IP address, for example http://server-address/about.html, and ensure the server is configured to accept that host and the network permits the connection. The filesystem-to-URL mapping remains the same: the path portion is relative to the configured root.

How Apache and NGINX map requests

Aspect Apache HTTP Server NGINX
Document-root directive DocumentRoot root
Default Ubuntu web directory described in the documentation /var/www/html /var/www/html
Request mapping example /fish/guppies.html maps to /var/www/html/fish/guppies.html The request URI is appended to the directory named by root
Directory index behavior index.html is conventionally served for a directory request without a filename Uses the configured index-file behavior; a root and commonly an index setting determine the file to try
Apply a configuration change on Ubuntu Restart the Apache service Reload the NGINX service
Failure logs identified in the documentation The active virtual-host and document-root configuration should be inspected Inspect access.log and error.log

The two servers perform the same essential job for a static page: they receive a URL, append its path to the configured web root, and return the matching file when it can be read. The directive name and service-management workflow differ, so troubleshooting should begin by identifying which server answered the request.

When the browser shows the default page

A default Apache or NGINX page usually means the request reached a different enabled virtual host or server block, or the expected filename is not present in the directory that is actually being served. It does not prove that /var/www/html is the active root.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Confirm the file path and spelling with ls -l /var/www/html/index.html.
  2. Check which server is running with systemctl status apache2 or systemctl status nginx.
  3. Inspect the enabled virtual-host or server-block configuration and find its active DocumentRoot or root.
  4. If you changed that configuration, restart Apache or reload NGINX as appropriate.
  5. Refresh the browser and request the exact hostname and path that the active configuration expects.

A hostname can select a different virtual host from the one you edited. Testing with localhost while the configuration is written for another hostname can therefore produce a default page even though your HTML file is correct.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Fixing a 404 Not Found

A 404 means the URL-to-file mapping did not find the requested path. Work from the URL backward:

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
  • For http://localhost/about.html, verify /var/www/html/about.html.
  • For http://localhost/fish/guppies.html, verify /var/www/html/fish/guppies.html.
  • For http://localhost/work/, verify the directory and its index file, such as /var/www/html/work/index.html.

Check capitalization, punctuation, and every directory component. A link to About.html will not find about.html. Also verify that the active root is the one you think it is; a correctly named file in an unused directory still produces a 404.

When NGINX handles the request, compare the browser’s timestamp with entries in access.log and error.log. The access log confirms the exact URI received; the error log can reveal the filesystem path NGINX attempted and why it failed.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fixing a 403 Forbidden or permission error

A 403 generally means the server found the requested path but could not traverse a directory or read the file. Check permissions on every directory in the path, not only the final HTML file. The web-server user needs directory traversal permission and file-read permission.

Do not assume there is one universal ownership command that is correct for every installation. Apache and NGINX may run under different service accounts, and changing ownership recursively can affect other applications. First inspect the permissions:

ls -ld /var/www /var/www/html /var/www/html/fish
ls -l /var/www/html/index.html

Correct the restrictive directory or file permission using the ownership and access policy appropriate for your system. Retest the exact URL after each change. If the file becomes readable but directory listing is still blocked, request the filename explicitly rather than relying on a directory index.

Do not enable directory indexes just to browse files

If http://localhost/ does not find an index file, some configurations may show a directory listing while others return an error. Ubuntu warns that exposing directory contents from the document root is usually undesirable. A listing can reveal filenames and internal structure that were never intended to be public.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prefer an intentional index.html for each directory that should have a landing page, and request known filenames directly during testing. Keep private files outside the web root instead of relying on a hidden filename.

A repeatable verification checklist

  1. Place: Put the page at /var/www/html/index.html or at the path matching the URL you plan to request.
  2. Spell: Compare URL and filename character for character, including case.
  3. Configure: Confirm Apache’s DocumentRoot or NGINX’s root points to /var/www/html.
  4. Run: Ensure the intended service is active and listening for HTTP requests.
  5. Reload: Apply configuration changes with an Apache restart or NGINX reload.
  6. Request: Open http://localhost/ for index.html, or append the relative filename for another page.
  7. Diagnose: Treat a default page as a host/configuration mismatch, a 404 as a path mismatch, and a 403 as a traversal or read-permission problem.
  8. Log: For NGINX failures, inspect access.log and error.log to correlate the request with the server’s decision.

Worked examples

One homepage

Suppose the only file is /var/www/html/index.html. The browser request http://127.0.0.1/ has an empty path after the host, so the server treats it as the document-root directory and tries its index behavior. With the conventional index file present, the returned document is /var/www/html/index.html.

Two pages and a subdirectory

Suppose the filesystem contains:

/var/www/html/index.html
/var/www/html/about.html
/var/www/html/levels/index.html
/var/www/html/levels/map.html

The corresponding requests are:

Browser URL Filesystem target
http://localhost/ /var/www/html/index.html
http://localhost/about.html /var/www/html/about.html
http://localhost/levels/ /var/www/html/levels/index.html
http://localhost/levels/map.html /var/www/html/levels/map.html

The server never expects the browser to send the filesystem prefix. Adding /var/www/html to the URL would ask for a directory literally named var/www/html below the document root and normally results in a 404.

What to retain

  • /var/www/html is a filesystem document root, not a browser address.
  • The browser uses the host plus a path relative to that root.
  • index.html is the conventional landing file for a directory URL.
  • Apache identifies the root with DocumentRoot; NGINX uses root and commonly an index setting.
  • After configuration edits, restart Apache or reload NGINX, then use the appropriate logs and path checks to diagnose failures.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.