Hosting

How to Host a Website: Free, on Your Own Computer, on GitHub, or on Real Hosting

Every way to host a website, from your own computer to real hosting: run it locally, share it from your PC for free, publish on GitHub Pages or Google's free options, or use shared hosting or a VPS. What each costs, with a tested sample site and commands.

A website being hosted on a computer, on free hosting and on a server

Hosting a website means putting its files on a computer that is always on and connected to the internet, so anyone can open them. That computer can be your own PC for testing, a free service for a simple site, or paid hosting for anything serious. The right choice depends on what your site is and who it is for.

This guide shows every way, with a small tested website to try them with, what each one costs, and where each fits.

The ways to host a website

WhereCostGood forRuns PHP and databases?
Your own computer, locallyFreeBuilding and testingYes (with XAMPP or Laragon)
Your own computer, shared to the internetFreeShowing someone a test versionYes
GitHub Pages, Cloudflare PagesFreeHTML, CSS and JavaScript sites, portfolios, docsNo
Google Sites, Firebase HostingFree (Firebase has paid tiers above its limits)Simple sites; Firebase for web appsNo PHP
Free PHP hostingFreeLearning PHP and MySQLYes, with limits
Shared hostingAbout $3 to $10 a monthBusiness sites, blogs, shops, PHP scriptsYes
A VPSAbout $4 to $20 a monthSeveral sites, apps, chat or VPN serversYes, anything

Try it: a small website to host

Save this as index.html in a new folder. It is a complete one-screen website for a local business, and it works on phones:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Sam's Bike Repair | Fast bike repairs in Leeds</title>
<meta name="description" content="Bike repairs and servicing in Leeds, usually done the same day. Call or WhatsApp for a price.">
<style>
  body { margin: 0; font-family: system-ui, sans-serif; color: #1e293b; line-height: 1.6; }
  header { background: #0f766e; color: #fff; padding: 48px 20px; text-align: center; }
  main { max-width: 720px; margin: 0 auto; padding: 24px 20px; }
  .btn { display: inline-block; background: #f59e0b; color: #1e293b; padding: 12px 22px; border-radius: 10px; font-weight: 700; text-decoration: none; }
  ul { padding-left: 20px; }
  footer { text-align: center; color: #64748b; padding: 24px; font-size: 14px; }
</style>
</head>
<body>
<header>
  <h1>Sam's Bike Repair</h1>
  <p>Fast, friendly bike repairs in Leeds. Most jobs done the same day.</p>
  <a class="btn" href="tel:+440000000000">Call for a price</a>
</header>
<main>
  <h2>What we fix</h2>
  <ul>
    <li>Punctures and new tyres</li>
    <li>Brakes and gears set up properly</li>
    <li>Full service before summer</li>
  </ul>
  <h2>Where to find us</h2>
  <p>12 Example Street, Leeds. Open Monday to Saturday, 9 am to 6 pm.</p>
</main>
<footer>© Sam's Bike Repair</footer>
</body>
</html>

How to host a website locally on your computer

Double-clicking index.html opens it, but a real web server behaves the way hosting will. Python has one built in:

# In the folder with your index.html (Windows, macOS or Linux, with Python installed)
python -m http.server 8000

# Then open http://localhost:8000 in your browser. Stop it with Ctrl+C.

On Windows, install Python from python.org or the Microsoft Store first, then run the command in PowerShell. For PHP sites, use XAMPP or Laragon, which add Apache, PHP and MySQL in one installer. Visual Studio Code's Live Server extension also serves a folder and reloads the page when you save.

How to host a website on your computer for free (for others to see)

To let someone else open the site running on your computer, without touching your router, use a Cloudflare Quick Tunnel. It needs no account:

# Share the site on your computer with anyone, for testing (install cloudflared first)
cloudflared tunnel --url http://localhost:8000

# It prints an address like https://random-words.trycloudflare.com that works until you press Ctrl+C

Use it for testing and demos only. Cloudflare says quick tunnels are not for production, and a website on a home computer goes down whenever the computer sleeps, restarts or your internet drops. Home connections also have slow uploads, and many internet providers do not allow servers on home plans.

How to host a website on GitHub for free

  1. Create a free GitHub account and a new public repository.
  2. Click Add file, Upload files, and upload your index.html (and any images or CSS).
  3. Open Settings, Pages, choose the main branch as the source, and save.
  4. After a minute your site is live at https://yourname.github.io/repository-name/. You can add your own domain on the same page.

Cloudflare Pages is similar: create a project, choose Upload assets, drag your folder in, and it gets a free pages.dev address with HTTPS. Neither runs PHP or a database.

How to host a website on Google: is Google site hosting free?

  • Google Sites is free: you build the site in Google's editor with a Google account and can add your own domain. You cannot upload your own HTML files, so it suits simple pages, not custom code.
  • Firebase Hosting (Google) hosts your own HTML, CSS and JavaScript with a free plan and paid usage above its limits, deployed with the Firebase command-line tool.
  • Google Cloud has a small always-free virtual machine in some US regions, which is a VPS you manage yourself.

How do I host my website for free with PHP and a database?

Free PHP hosts such as InfinityFree still exist, with limits on traffic and no email sending. Our guide on hosting a PHP website for free walks through it with a tested guestbook. For a free server you control completely, see the Oracle Cloud free tier.

How can I host my own website for real?

For a site that has to be up every day, pay for hosting. It is cheaper than most people expect:

  1. Buy a domain (about $10 to $15 a year for a .com).
  2. Choose hosting: shared hosting for most sites (compare cheap hosting by the renewal price), or a VPS for apps (see shared vs VPS vs dedicated).
  3. Connect the domain to the hosting (see how to connect a domain).
  4. Upload your site with the file manager or FTP (see how to upload a website to cPanel), and turn on the free SSL certificate.

On a VPS, the simplest web server takes three commands:

# On an Ubuntu VPS: install a web server and put your site in its folder
sudo apt update && sudo apt install -y nginx
sudo cp index.html /var/www/html/index.html
# Now open http://YOUR-SERVER-IP in your browser

Then add a domain and HTTPS, and secure the server first (see how to secure an Ubuntu server).

How much does it cost to host a website?

ItemTypical cost
Domain$10 to $15 a year (.com)
Static site on GitHub Pages or Cloudflare Pages$0
Shared hosting$3 to $10 a month after the first-term discount
VPS$4 to $20 a month for most small projects
SSL certificate$0 (Let's Encrypt, included by most hosts)
Email at your domain$0 to a few dollars a month (see free email with your domain)

So a real business website costs roughly $50 to $130 a year on shared hosting with a domain.

What people on Reddit usually recommend

  • Static site? GitHub Pages or Cloudflare Pages, free and fast
  • Do not host a real site on your home computer
  • For WordPress or PHP, cheap shared hosting is enough; compare renewal prices
  • Learn on a cheap VPS when you want to understand servers

Running a website people depend on

Hosting the files is only the start. A site for a business also needs daily backups stored elsewhere, HTTPS everywhere, monitoring that tells you when it is down, fast pages on phones, analytics, and someone who installs updates. Good shared hosting handles much of that for you; on a VPS it is your job.

A complete website to host

If you want more than a single page, our PHP scripts are complete websites that install on normal shared hosting in minutes:

Where to go next

Questions people ask

How can I host my own website?
For a real site, buy a domain, choose shared hosting or a VPS, connect the domain to it, upload your files and turn on the free SSL certificate. For testing, run it on your own computer with a local web server.
How do I host my website for free?
Static HTML, CSS and JavaScript sites can be hosted free on GitHub Pages or Cloudflare Pages. PHP and MySQL sites can use a free host such as InfinityFree. For a free server you control, Oracle Cloud's free tier gives you a VPS.
How much does it cost to host a website?
A static site can cost nothing. A typical business site costs about $3 to $10 a month for shared hosting plus $10 to $15 a year for a domain, so roughly $50 to $130 a year. A VPS costs about $4 to $20 a month.
Is Google site hosting free?
Google Sites is free for sites you build in Google's editor. Firebase Hosting, also from Google, hosts your own HTML, CSS and JavaScript with a free plan and paid usage above its limits.
How do I host a website on my own computer?
Run a local web server in the site's folder, for example python -m http.server 8000, and open http://localhost:8000. To let others see it for a test, a Cloudflare Quick Tunnel gives you a temporary public address.
Can I host a website on my computer for free permanently?
Technically yes, but it is not a good idea: the site goes down whenever your computer or internet does, home uploads are slow, and many internet providers do not allow servers on home plans. Free static hosting is more reliable.
How do I host a website on GitHub?
Create a public repository, upload your index.html and files, then in Settings, Pages, choose the main branch. The site appears at yourname.github.io/repository-name, and you can add your own domain.
How do I host a website on Windows?
For testing, install Python and run python -m http.server in the site's folder, or use XAMPP or Laragon for PHP. For a public site, use hosting rather than your Windows PC.
What does it mean to host a website locally?
It means running the website on your own computer with a local web server, so only you can open it at an address like http://localhost:8000. Developers do this while building and testing a site.
Do I need a domain to host a website?
No, free hosts give you an address such as yourname.github.io. A domain of your own looks more professional and stays yours if you move hosts, for about $10 to $15 a year.

Written by Habib Baloch

I build Android apps, websites and Ubuntu servers, and write down exactly how I did it.

Ask me about this guide →