Raspberry Pi Web Server
A Raspberry Pi web server makes for a great lightweight Web Server. It can handle a small amount of traffic and lightweight scripts making it fantastic for a home server or an area you can learn web programing languages such as PHP.

The Pi can even handle WordPress so if you want to launch your own blog/website with a proper back-end you can easily do it. If you want it to be accessible via the internet you will need to do some port forwarding.

This web server is only really suitable for a small amount of traffic and/or development purposes. If you want to setup a website that you plan on driving a lot of traffic to then you might want to take a look into shared, cloud or dedicated web hosting.

If you want to see it done visually then check out my video I have prepared for you below. If you like it then please subscribe so you stay up to date with all the latest Pi videos.


I used the following equipment for this Raspberry Pi web server project.


Raspberry Pi

4GB SD Card (8 GB+ Recommended) or Micro SD Card if you’re using a Raspberry Pi 2 or B+

Ethernet Cord or Wifi dongle


USB Keyboard

USB Mouse

Installing the Raspberry Pi Web Server

In this tutorial I make use of the standard operating system for the Raspberry Pi known as Raspbian. If you haven’t got this installed then you can follow my guide that will take you from start to finish on installing NOOBS (Raspbian) on the Pi.

You can do this tutorial via Raspberry Pi SSH or via the terminal on the actual Pi.

If you’re using a different operating system then most the syntax will remain the same.
1. Firstly, update the Raspberry Pi so you’re running on the latest packages. You can do this by running the following commands.

sudo apt-get update
sudo apt-get upgrade

1. Next we will need to install the apache2 package:

sudo apt-get install apache2 -y

2. Now that’s all you need to do to have the server up and running. To check that it is working you should be able to enter the Pi’s IP address. If you don’t know the IP you can enter the following line:

hostname -I

3. Browse to the IP address in a browser and you should get a page like the one below.
Web Server Default Page
4. Now you’re able to edit this basic file by simply entering the following command.

sudo nano /var/www/html/index.html

5. You can now add as many new web pages as you want in the www folder and they will be viewable from the browser.

6. This is a very basic server and is great if you just want to learn HTML, JS or CSS but if you’re after PHP (Used for dynamic web pages) then read on.

7. To install PHP we will need to first get the PHP package so lets download the PHP5 module for apache. To do this enter the following:

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

8. Now we can place php files in the www and they will be processed and displayed. For an example let’s make a file called example.php

sudo nano /var/www/html/example.php

9. In this file add the following:

echo "Today's date is ".date('Y-m-d H:i:s');

There we have it a fully working Apache2 + PHP Raspberry Pi Web Server working. Now you’re able to have mix of HTML and PHP files all in the www folder but personally I would do all my web pages in PHP to keep it consistent. (You can have normal HTML outside the <?php ?> tags).

Now if you want to install WordPress then please keep reading! Otherwise you should check out some great PHP and HTML resources and learn more about these great Web technologies. (Simply google either of these and you will find a ton of great tutorials w3schools is a great starting point)

Install Raspberry Pi WordPress

WordPress is a content management system/blogging software that is used by over 60 million websites. Amongst the top 10 million websites on the web 23.3% of these use WordPress. (January 2015).

It is very easy to install & learn the basics making it a great way to launch your very own website or blog. Installing Raspberry Pi WordPress on to our web server is dead easy and can be done in just a few steps detailed below.
1. Now we have already installed PHP but we will also need MySQL and the MYSQL PHP packages.

sudo apt-get install mysql-server php5-mysql -y

You will be asked for a root password make sure you remember this as we will need it to access the database.

2. We will need to now download and extract the WordPress package that we can easily download. To do this do the following commands:

cd /var/www/html
sudo chown pi: .
rm *
wget http://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz
mv wordpress/* ./
rm -rf wordpress latest.tar.gz
sudo chown -R -f www-data:www-data /var/www/html

3. Now that’s installed we will need to setup a database to connect to. Now we could install PHPMyAdmin for database management but instead we will do it via command line.First we need to use the mysql command to login, use the –p flag for the password and –u for the username. Leave no space between the flag and required text.

mysql -uroot -ppassword

4. Now let’s create a database for this tutorial let’s call it WordPress.

create database wordpress;

5. You should now see a success statement that looks something like the following:

Query OK, 1 row affected (0.00)

6. Now let’s exit out of MySQL prompt by pressing Ctrl + D

7. Now in a browser go to the Pi’s IP address and you should be presented with a WordPress setup screen. Fill in the relevant information such as:
Database Name: wordpress

User Name: root

Password: (Password you created at the MYSQL setup)

Database Host: localhost

Table Prefix: wp_

Wordpress Setup

8. Now you should be now able to hit next to complete the installation. If an error occurs then this might mean the permissions are incorrect for your web folder, make sure that www-data is able to read and write to this folder.

Be sure to check out my Raspberry Pi PHPMyAdmin tutorial if you would like to learn how to install PHPMyAdmin. If you have never heard of PHPMYAdmin, to put it simply it’s a database management tool that makes managing and configuring databases extremely easy.

You should now have a fully working version of WordPress on your Raspberry Pi. Running more than one copy on a Raspberry Pi web server might not work to well due the limited resources available to the Pi. However as I mentioned above it makes for a great home web server.

Pi Book Small Pi Book Large
The Raspberry Pi Crash Course

The Raspberry Pi Crash Course

Enter your email address below to get the

Raspberry Pi crash course delivered straight to your inbox

Please check your inbox for a confirmation email!