Host your own website on a Raspberry Pi 3

A comprehensive step by step guide, covering everything you need to know to , host and maintain a Website running on a Raspberry Pi shared across the internet.
A Raspberry Pi 3 Model B


  1. Raspberry Pi 3
  2. Raspberry Pi power adapter
  3. 8 GB (or greater) micro SD Card class 10 (or faster) (and a card reader, duh)
  4. Router with internet & Ethernet port
  5. Network cable
  6. Monitor with an HDMI connection, USB Keyboard and USB mouse (temporarily for the initial setup)
  7. Can-do attitude!

The Plan

a. Requirements
b. Preparing your Raspberry Pi
c. Installing your Apache server 
d. Getting It Online with Static IP
e. SSH-ing the Pi

Preparing your Pi

To start we need to prepare the OS on the SD Card, setup the hardware and connect everything for initial setup.

  1. Download New Out Of Box Software (NOOBS - an easy operating system installer which contains Raspbian) image here ( Use Offline installer).
  2. Format the micro SD Card (use FAT32 file system).
  3. Install Raspbian image on the SD Card using NOOBS installer. Follow the official guide:
  4. Insert the micro SD card into the slot and attach the keyboard, mouse, HDMI monitor and network cables. Finally attach the power cable and turn on the power to start your RPi.
  5. When your RPi boots up, go to Menu > Preferences > Raspberry Pi Configuration.
  6. Use the up and down arrow keys to move the highlighted selection between the options available and select Advanced Options , and update to upgrade all your installed packages to their latest versions.

Installing your Apache server

Next run the following command. This will install Apache server, which is a web server that responds to HTTP requests:

sudo apt-get install apache2 php5 libapache2-mod-php5

now execute the below command to restart Apache with your new settings.

Technically, this is all we need to do to run a very basic web server from our RPi. Give it a go, pop the IP address of your Raspberry Pi in your web browser. You should see a default web page like this:

This means you have Apache working! 👍

This default web page is just a HTML file on the file system. It is located at /var/www/html/index.html . Now go ahead and paste your webpages after enabling permissions.

Getting It Online with Static IP

You can access and edit your website, but it’s only visible to you on your local network. So how do you get your Web server on the actual Web, not just your local network? You need to set port triggers and register your RPi.

Here are some port forwarding tutorials for major router manufacturers:

Now you’ve got a human-readable domain name that forwards to the Pi’s IP address.

SSH-ing the Pi

We don’t need to have the RPi always attached to the keyboard, mouse and monitor. We can login remotely from a system and continue setting up everything hassle-free.Go to Menu > Preferences > Raspberry Pi Configuration and Enable SSH and reboot you RPi.

Now you will be able to SSH into your Pi, so you can work on it from another computer if you’d like to, with the below default credentials.

username : pi
password : raspberry

Huzzah! That’s it ! 😎