16 Jan '13 How to set up a full web server on a Raspberry PI

In this post I am going to show you how to set up a fully operative web server on Raspberry PI. More specifically, this a LAMP server, which means Linux+Apache+MySQL+PHP, which the most common combination you find in most of the servers worldwide.

Refresh all your packages

Just before we start, it is indicated to refresh all your repositories, in order to get the most updated version of every software we are going to install. To do that, simply type the following command:

sudo apt-get update

Apache web server

sudo apt-get install apache2

Doing this, you have installed now the Apache web server on your Raspberry PI.


To install MySQL, the Oracle-developed world’s most famous RDBMS:

sudo apt-get install mysql-server


In order to be able to view your PHP made websites, you will have to install PHP5, typing:

sudo apt-get install php5
sudo apt-get install php5-mysql

The second line will install the libraries that make PHP5 able to connect to the MySQL database.

Ready to go!

Your web server is now ready and working, and you can test it by visiting (from a browser) http://localhost/. You can place all your websites’ folders and files at the following path: /var/www/html/.

Working with MySQL

As you will most probably need to work with one or more database, you may want to use a web interface for that. Adminer is a great, lightweight and very fast database management tool. To use it, simply type the following commands:

cd /var/www
mkdir adminer
cd adminer
sudo wget http://www.adminer.org/latest-mysql-en.php
mv latest-mysql-en.php index.php

Now, if you try to visit http://localhost/adminer from a browser, you should see your database management interface. To access it, simply insert the MySQL username and password you chose while installing it.

In alternative, if you don’t like Adminer’s very simple interface and you want a much more graphical and powerful UI, you should give a try to Chive, a wonderful database management tool developed with the Yii framework! Install it by typing:

cd /var/www
wget -O - http://www.chive-project.com/Download/Redirect|tar -xzp

Visiting http://localhost/chive you will be able to work with Chive.

Update: Chive does not appear to have been updated recently. It is therefore no longer a recommended choice.


That’s all you need to be fully operative with a webserver running on your Raspberry PI. With very few or no changes, the above guide will also help you to install a LAMP web server on Ubuntu and Debian operating systems.

See also