Sunday 26 January 2014

Setting up an Apache web server on a Raspberry Pi

This guide will show you how to set up an Apache web server on Raspberry Pi by installing a LAMP (Linux, Apache, MySQL, PHP) stack. This is with the Raspbian Wheezy Debian Distribution. Make sure that you have resized the root partition of the SD card before doing this as it takes up a lot of space. You can resize the root partition from the raspi-config interface.

First we need to make sure that the package lists are up to date by running:

sudo apt-get update

After that's all done enter this:


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

This will install the Apache web server as well as PHP and MySQL. It will take quite a long time to install so be patient.

About halfway through you will be prompted by MySQL to enter a password (make sure it's secure).

When it has all finished installing, you can test whether the web server is up and running by entering the IP address of your pi into a web browser on a computer on the same network. If you do not know the IP address you can enter the command ifconfig on the Pi and look for the IP address. 

The webpage should look like this:


It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.


If you get this page then you have successfully installed Apache web server on your Raspberry Pi.

The files in the web server are stored in /var/www/


If it didn't work try going over the steps above again and make sure that you 
have enough space on your SD card and you have expanded the root partition 
of the SD card.

No comments:

Post a Comment