How to Install the LAMP stack on a Raspberry Pi

Execute the following:

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

This cost me 116 MB including the dependencies, and took about 10 minutes to finish. Part way through you will be asked to make a password for MySQL.

Locate the IP address of the RpI by executing ifconfig:


On another computer in your LAN, enter that IP address in your browser and confirm the following result:


Confirm that the PHP module has been correctly loaded into Apache by executing the following command:

sudo sh -c 'echo "<?php phpinfo(); ?>" > /var/www/phptest.php'

and on another computer going to http://youripaddress/phptest.php


You can remove the phptest.php file by:

rm /var/www/phptest.php

The /var/www folder is by default where files are stored for the web server, and is writable by the root user only. To change this location, edit /etc/apache2/sites-enabled/000-default


Add Comment




Are you human? * six = 42