Want to host your own website without needing heavy server resources? Turn your Raspberry Pi into a reliable personal web server for creating, hosting, and maintaining sites effortlessly. This expert guide walks you through installing Apache, configuring PHP, and building dynamic pages accessible on your local network.
By the end, you'll have a fully functional web server on your Raspberry Pi, drawing from proven setups used by developers worldwide.
Apache powers nearly 40% of the world's web servers, making it a trusted choice for reliable hosting. Once installed on your Raspberry Pi, it serves files to anyone on your local network with ease.
To follow this tutorial:
Connect your peripherals and power on the Pi. Open the Terminal from the toolbar and run:
sudo apt-get update sudo apt-get upgrade
If updates install, reboot with:
reboot
Your Pi now runs the latest Raspbian.
Install Apache2 via Terminal:
sudo apt install apache2 -y
Your Pi is now a basic web server! Find its IP with:
hostname -I
Enter the IP in any browser on your network to see the Apache default page.

To edit the default file, take ownership (assuming username 'pi'):
sudo chown pi: /var/www/html/index.html
Verify with ls -al /var/www/html/.

Edit index.html:
nano /var/www/html/index.html

Modify the content, e.g., update the header text.

Save with Ctrl+O, then Ctrl+X. Refresh the browser IP to see changes.

Apache serves static files by default. Add PHP 7.4 (or latest) for interactivity:
sudo apt install php libapache2-mod-php -y
Create a test file:
sudo nano /var/www/html/mywebpage.php
Add:
<?php
echo "Today is " . date('Y-m-d H:i:s');Save with Ctrl+O, Ctrl+X.
Visit https://YOUR_IP/mywebpage.php (replace YOUR_IP).

It's straightforward to host on your Pi locally. For public access, configure dynamic DNS. This setup has powered countless personal projects reliably.