Introduction: How to Make a Website for Free Using a Raspberry Pi 2

About: Plz No.....

Today we are learning how to make a website entirely for free with a raspberry pi 2 (or 1 or 3). We will be using Raspbian so first start by installing it. How To Install Raspbian. You will need a keyboard, mouse, monitor and Ethernet connection. Then you open the terminal by clicking the menu button and selecting the terminal. Now onto step two.

Step 1: Set Up the Apache Web Server

Now we need to setup the Apache 2 web server. Install it by typing

sudo apt-get install apache2 -y 

into the terminal. Apache has a test page to tell you it is working. To view this you need to type the raspberry pi's ip adress into a web-browser (use Chrome, Firefox or Safari). To find the ip adress of the Pi you type

sudo ifconfig 

into the terminal. In the terminal, near the line saying wlan0 you will see inet addr: followed by some numbers. write this string of numbers down with the fullstops.

now type http:// followed by the ip adress (with the fullstops) into the adress bar of google chrome on another computer connected to the same network.

Step 2: Changing the Default Webpage

Now we need to change this default test webpage. in the terminal navigate to the directory where it is located by typing

cd /var/www/html 


ls -al 

Some text will show up in the terminal.

Now install PHP by typing

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

Install mySQL with:

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

you will be asked to create a root password by mySQL. Set this password to 'password' (no quotes).

Now restart apache:

sudo service apache2 restart

Step 3: Download and Install Wordpress

Now to download and install wordpress.

Open the file manager, navigate to /var/www/html and delete everything in it. If you need admin privileges type into the terminal

sudo chown -R pi /var/www

Then type

cd /var/www/html

into the terminal (after deleting the apache test file). To download wordpress you type

sudo wget

into the terminal. now run the following commands:

sudo tar xzf latest.tar.gz
sudo mv wordpress/* . 
sudo rm -rf wordpress latest.tar.gz

now change the ownership of these files using:

sudo chown -R www-data: . 

Step 4: Setup the WordPress Database

close the terminal window you have open and open a new one. type:

mysql -uroot -p

you will be prompted to enter your password which is 'password' (no quotes). to create the database type:

mysql> create database wordpress;

If it works you will see:

Query OK, 1 row affected (0.00 sec)

Exit out of mySQL using the keyboard command

Ctrl + D

Step 5: Setup Wordpress

now type http:// followed by the ip adress (with the fullstops) into the adress bar of google chrome on another computer connected to the same network.

This should bring up the WordPress welcome page.Click the Let's Go button.

Fill out the basic info as follows:

Database Name:      wordpress<br>
User Name:          root
Password:           password
Database Host:      localhost
Table Prefix:       wp_

(password above is what ever you set the mySQL database password to earlier in the tutorial. Mine is 'password').

Click submit to submit it.

now click run the install.

Fill out the information: give your site a title, create a username and password and enter your email address. Hit the Install WordPress button, then log in using the account you just created.
Now you're logged in and have your site set up, you can see the website by visiting your IP address in the browser on the Pi or another computer on the network. To log in again (or on another computer), go to


Step 6: More WordPress Configuration

It's recommended that you change your permalink settings to make your URLs more friendly.

To do this, log in to WordPress and go to the dashboard. Go to Settings then Permalinks. Select the Post name option and click Save Changes.

You'll need to enable Apache's rewrite mod:

sudo a2enmod rewrite

You'll also need to tell the virtual host serving the site to allow requests to be overwritten. Edit the Apache configuration file for your virtual host:

sudo nano /etc/apache2/sites-available/000-default.conf 

Add the following lines after line 1:

<Directory "/var/www/html">
	AllowOverride All

ensuring it's within the <VirtualHost *:80> like so:

<VirtualHost *:80>
	<Directory "/var/www/html">
		AllowOverride All

And then restart Apache again:

sudo service apache2 restart

Step 7: Installing Localtunnel

So we are using localtunnel to get our website on the internet. To install localtunnel we first have to install npm:

sudo apt-get npm 

then we use npm to install localtunnel:

sudo npm install -g localtunnel

Step 8: Use a Script to Keep Localtunnel Running.

Because localtunnel can't keep tunnel's open for very long, a script has been written to keep localtunnel running over long periods of time.

To run this script you need ruby:

sudo apt-get install rubygems

Step 9: Now Get on the Internet :)

You need to save this script to the /home/pi folder of your raspberry pi. You should call the script localtunnel.rb

you can find a download for the script here. download it and put it in the home folder of your raspberry pi. don't open it, don't rename it and don't edit it.

run the script by typing:

ruby localtunnel.rb --port 3000 --subdomain yourdomainhere<br>

You replace 3000 with whatever port you want to use. you also replace yourdomainhere with whatever you want. eg: itsawebsite

A link will show up once you press enter. write this link down.

Don't close this terminal window ever.

Step 10: Get a Domain.

Now if you want a domain you can go to and register for one there. (for free) When it says dns or domain forwarding, choose domain forwarding. The link for domain forwarding is the one that appeared in the terminal or your raspberry pi in the previous step. Give them your details and then you are done.

Don't forget to leave a like on my youtube channel for more awesome tech related stuff.

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017