Host a Website at Home with Raspberry Pi: Step-by-Step Guide
Did you know that the Raspberry Pi has the perfect blend of hardware and software to host a website from home? But if you’re new to web tech, you might be intimidated by all the lingo. So in this post, I’ll explain it in the simplest language possible—human to human.
To host a website on Raspberry Pi, you must install a web server to serve pages. The Raspberry Pi must also be open to the internet so visitors can find the site.
This article is not meant to be a technical deep dive but rather an umbrella guide. For each step, I’ll provide links to our tutorials so you can focus on them separately. When you’re done with each part, you can return here to continue your journey. Steady as she goes!
If you’re new to Raspberry Pi or Linux, I’ve got something that can help you right away!
Download my free Linux commands cheat sheet – it’s a quick reference guide with all the essential commands you’ll need to get things done on your Raspberry Pi. Click here to get it for free!
Overview

It’s easier to achieve that sweet, sweet http if we keep the bigger picture in mind.
Here are the broad brush strokes you’ll need to take to create a website on Raspberry Pi:
- Install a web server on Raspberry Pi.
- Create new pages for your site.
- Make your website accessible to visitors on the internet.
- Take security precautions on your Pi to stop bad actors.
Use the table of contents below to jump directly to the section you’re interested in:
Hardware Requirements to Host a Website on Raspberry Pi
To host a website on your Pi, here’s a list of the hardware you’ll need:
- Raspberry Pi: The newer models like the Raspberry Pi 5 or Pi 4 are what I usually recommend, but older boards should be able to handle a web server just fine.
- Memory: 512 MB RAM minimum. Check how much you have.
- Storage: 256 MB disk space or more recommended.
You can use my current favorite SD card, a USB drive, or an NVME drive. - Network: I recommend an Ethernet connection for speed and stable uptime.
Wi-fi will still work if you’re trying things out.
Now that the hardware is covered, let’s start installing some software. I presume you already installed Raspberry Pi OS, but you can click on the link if you haven’t.
How to Get a Web Server on Raspberry Pi
In this section, you’ll install the key packages to run a website. Specifically, you’ll learn how to:
Members get an ad-free version of every guide, plus exclusive project support.
Join the Community | Sign In
- Install a web server.
- Add common website components to get advanced functionality.
- Create pages for your site.
Note: If you want to see these steps in action, I have a video course just for community members where I explain everything you need to do (including firewall configuration, port forwarding, and SSL certificates).
1. Install a Web Server
The web server is the application on your Pi that serves pages when visitors drop by.
It sends out HTML code and images from your files to display pages in a web browser.
The two most popular web servers are: Apache and Nginx.
Which one should you choose? The short answer: it probably won’t matter for a self-hosted website at home, as they both run well on Raspberry Pi. Let’s touch on both briefly.
Check this: Need a clear GPIO pinout diagram? Here's mine.
Apache
Apache is the traditional web server with the most community guides available.

Read our full installation guide: Apache Web Server on Raspberry Pi.
Nginx
If you prefer to be part of the vanguard, Nginx is newer and designed to be more performant.

Read our full installation guide: Nginx Web Server on Raspberry Pi.
Luckily for you, we’ve already written guides for both. Choose one and install it to get started.
Download the free PDF, keep it open, and stop wasting time on Google.
Download now
2. Install Optional Web Server Components

A web server is all you need if your pages are basic and static (don’t change).
Maybe it shows images of robots you’ve photographed and shares your email address.
But that design philosophy was Web 1.0 thinking, practically the dinosaur age.
Today, websites are dynamic.
You might also like: Do this to keep a full backup of your Raspberry Pi
For example, you might want to let users log in, leave comments on your robot videos, or sort information on new gadgets that get updated regularly. So to make dynamic content possible, you want to install additional components onto your web server.
These extra parts working together are known as your website stack.
So, you won’t always always hear the discussion as Apache vs. Nginx.
Instead, you might see LAMP vs. LEMP.
Here’s what these terms mean:
- LAMP stack: Linux + Apache + MySQL + PHP
- LEMP stack: Linux + Nginx (pronounced “Engine-X”) + MySQL + PHP
You’ve already got the Linux part because you’ve been running it on your Raspberry Pi.
And if you completed the step above, you already have the web server.
So next, let’s install the PHP and MySQL parts of your stack.
Integrate PHP to Run Web Code

PHP is a programming language that runs code on web pages.
HTML displays basic web pages, but PHP lets those pages perform advanced functions.
For example, you could use PHP to write a page that dynamically changes what’s displayed based on what a user clicks. For instance, shuffle the robot kits displayed on a featured slideshow. Only show Raspberry Pi HATs that are in stock. Stuff like that.
I’m sure you’ve heard of other programming languages like Python, C++, or Node.js, and yes, you could run these on your website (with extra effort, as big tech companies do).
But PHP was designed for the web. It integrates with your web server with a single line change. In other words, it’s the most common and easy approach. When I install Apache or Nginx on a new server, I install PHP.
In both our tutorials for LAMP and LEMP above, you’ll:
- Install PHP on your Raspberry Pi.
- Integrate PHP by modifying the web server’s configuration file.
Go ahead and take these steps before you continue.
Add a Database to Store Data

Think of a database as an advanced spreadsheet for the web.
A web server pulls information from a database to display on a page.
Modern websites store lots of data: everything from usernames/passwords to inventory lists for shopping sites. The most efficient way to organize this data is with tables, and the best way to manage these tables is with a database.
If I change info in my database, like the price of a Raspberry Pi AI kit, that new information will automatically be updated on any page that uses the database. It’s much more efficient and future-proof than changing the HTML for every page.
Download the free PDF, keep it open, and stop wasting time on Google.
Download now
It’s common practice to install a database alongside the web server.
There are many choices available for databases on Raspberry Pi.
Let’s go over the two easiest ones to install for your site.
MySQL

When most people start, the database they’ll hear about most often is MySQL.
MySQL has been the free database standard for a long time in the web hosting world.
Both our guides on Apache or Nginx include instructions for installing MySQL:
MariaDB

More recently, however, Raspberry Pi OS and other Linux distros have been shifting to a new default database: MariaDB.
MariaDB is made by the same developers who originally made MySQL. It’s more efficient with a smaller footprint, perfect for conserving resources on a Raspberry Pi.
Which database should you choose? I recommend MariaDB on Raspberry Pi.
Once installed, MariaDB’s key commands are identical to MySQL.
So you’ll get better performance, but the old knowledge and guides will transfer over.
Read our guide to begin: How to Install MariaDB on Raspberry Pi? (MySQL Server).
Tip: Managing databases via the command line can be a huge pain.
To edit tables visually from a browser, try using phpMyAdmin.
Some of our tutorials above contain a section on how to install phpMyAdmin.
How to Create Website Pages
So you’ve got your website stack, congrats! Now what?
In this section, I’ll share a few ways to create pages for your site.
Manual HTML Coding
You can write HTML from scratch using pure text.
AKA, hard mode. It’s a great way to learn but very time-consuming.
I haven’t done it this way in a long time.

HTML Editors
Also called WYSIWYG editors, these apps let you create webpages from a graphical interface.
For example, Adobe Dreamweaver, Visual Studio Code, and other editors will include tools to help you code websites more efficiently and preview pages as you make them.

Note: If you’re using these apps from your PC, you’ll have to transfer the pages/images to your Raspberry Pi once you’re done. To do this, you could use SFTP with Termius or set up your own FTP server.
Content Management System
Download the free PDF, keep it open, and stop wasting time on Google.
Download now
If making web pages with the methods above still sounds like too much work, now you know why many companies prefer to use a content management system (CMS).
A CMS is a site builder that runs on your website itself.
It lets you make pages and publish them straight from your browser.

You have a lot of options for a CMS out there, but popular ones are:
A CMS like WordPress is my preferred way of launching websites quickly. I can select a theme that keeps the design consistent and use plugins to handle advanced functions.
It sits on the web server from the start, so that lets me focus on managing content instead of fiddling with the server all day.
Read our full guide: How to Install WordPress on Raspberry Pi (Illustrated).
How to Make a Website Available Online

Now you’ve got a web server up and running on your Raspberry Pi. But your website probably won’t load for visitors from outside your home. In this section, I’ll show you how to make it reachable over Internet.
During testing, you probably viewed your pages by visiting your Pi’s local IP address. For example, you might have typed something like http://192.168.1.10 into your browser.
People outside of your private network need your public IP address to visit your site.
Your public IP address is issued by your internet service provider (ISP).
But if a friend were to visit it right now, she might find that your website won’t connect.
What gives?
There are three obstacles in the way:
- Your internet router has a firewall that blocks strangers.
- If users do visit, they need to be directed to the Raspberry Pi to see the website.
- Your ISP might change your public IP address regularly.
I’ll show you how to vanquish these problems one by one using home networking techniques.
1. Assign the Raspberry Pi a Static IP Address
First, you want the Raspberry Pi to have a consistent IP address on your home network.
Your router will assign local IP addresses to devices in your home. It can be different each time your Pi reboots. This randomness is a headache for a website.
A static IP address makes it easier for the router to send traffic to the Raspberry Pi.
There are different ways to do this. My favorite method is to set it on the router’s admin panel.
Follow our guide: Set a Static IP Address on Raspberry Pi.
2. Activate Port Forwarding to the Raspberry Pi

Next, you want to open the router’s firewall to allow web traffic to your Raspberry Pi.
Set port forwarding rules on your router to tell public visitors where to go.
We want the router to direct users from a web browser to your Pi.
Download the free PDF, keep it open, and stop wasting time on Google.
Download now
You might also like: I tried to replace my main PC with a Pi 5, here's what happened.
Open your router’s admin panel to set it up. You’ll want to create port forwarding rules that send TCP traffic on port 80 (for http://) and port 443 (for https://) to your Pi’s static IP address. I’ll link you to a guide in the next section that includes how to do it.
3. Get a Domain Name

Finally, you’ll want a domain name to give to visitors.
Sure, you could give out your public IP (like 94.140.14.14), but who will remember that?
Plus, remember that your ISP can change your IP address whenever.
That’s where domain names (like raspberrytips.com) come in handy. A domain name is constant, so even if your public IP changes, visitors will still know where to find your website.
You could buy a domain name, which will sound nicer and look more professional.
But if you’re testing the waters, you can get a free domain name to start.
Follow our guide: Install No-IP to Get a Free Domain Name on Raspberry Pi.
If you’ve taken the steps above, here’s how it all comes together. A visitor browses your domain name and gets sent to your home’s public IP. Your router forwards the traffic to your Raspberry Pi. The Pi’s web server sends the page to be displayed by the browser. Nice!
You might also like: Want to install Windows 11 on your Pi? Here's how
Security for Hosting a Website on Raspberry Pi

Of course, exposing your Raspberry Pi to the wider internet should never be done lightly!
Roaming bot gangs on the internet constantly scan for targets to hack, and your Pi and website are juicy targets. You’ll want to harden your server, which means tightening its security.
Here are some steps you can take to harden your server, along with links to our guides:
- Install Cloudflare Tunnel to hide your public IP address.
- Install Fail2Ban to block brute-force attacks.
- Scan your server to find and close vulnerable ports.
- Put up a firewall on your Raspberry Pi to limit access.
- Install an antivirus to catch malware uploads.
- Protect your Pi like a pro with system security tips.
Congratulations on making it to the end. If you’ve succeeded in hosting a website on your Raspberry Pi, I look forward to visiting soon!
Want to connect with other Raspberry Pi fans? Join the RaspberryTips Community. Ask questions, share your projects, and learn from each other. Join now.
Related Questions
Are there other ways to install a web server if I don’t want to do it from the command line?
Yes. Some server administration apps have a graphical interface that will install Apache or Nginx for you. If you’d like to take this route instead, read more about them in our guides:
Can running a web server wear down my storage device?
Possibly. Web servers tend to perform a lot of logging, especially if you’re running a CMS or doing security monitoring. These activities lead to many disk read/writes.
To prevent stress on your Raspberry Pi’s SD card, I recommend installing Log2RAM.
You might also like: 25 project ideas you can try at home with Raspberry Pi
Can I use a Raspberry Pi to send emails from my custom domain?
Yes. If you want to host email yourself, you have to set up an email server.
This is not a task for the faint of heart! Email security has evolved significantly to combat spam, which has made it much more difficult to configure email servers than in the past.
But maybe you’re curious, stubborn, or just want to learn.
If so, we’ve written a guide: How to Install an Email Server on your Raspberry Pi.
Whenever you’re ready, here are other ways I can help you:
Test Your Raspberry Pi Level (Free): Not sure why everything takes so long on your Raspberry Pi? Take this free 3-minute assessment and see what’s causing the problems.
The RaspberryTips Community: Need help or want to discuss your Raspberry Pi projects with others who actually get it? Join the RaspberryTips Community and get access to private forums, exclusive lessons, and direct help.
Master your Raspberry Pi in 30 days: If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.
Master Python on Raspberry Pi: Create, understand, and improve any Python script for your Raspberry Pi. Learn the essentials step-by-step without losing time understanding useless concepts.
You can also find all my recommendations for tools and hardware on this page.
