How to install LAMP in Raspberry Pi?

install LAMP in Raspberry Pi

This post will discuss how to install LAMP (Linux Apache MySQL PHP) in Raspberry Pi. This procedure was tested under Raspberry Pi 3 Model B with Rasbian OS version 8 (Jessie).

* Part 1: Install Apache and PHP

1. Open shell and update the OS using the following command:

sudo apt-get update && sudo apt-get upgrade

2. Install Apache and PHP by typing the command below in the shell followed by enter key:

sudo apt-get install apache2 php5 libapache2-mod-php

3. Wait for the installation to finish

To check if Apache server is installed and running after installation, open browser and type the Raspberry Pi address (ex. You should see the following page in the browser:


* Part 2: Install MySQL

1. Install MySQL server using the following command:

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

2. You will be guided by on screen steps, asking to supply password, etc. similar to image below:


Make sure to take note of the password entry!

* Part 3: Install PHPMyAdmin

1. Use the following command to install PHPMyAdmin:

sudo apt-get install phpmyadmin

2. Similar to MySQL server installation, there will be an on screen steps to follow. What to do in those steps are indicated below:

a. Select apache2 as Web server

b. Config with dbconfig-common and enter mysql root password

c. Run command the following command:

sudo nano /etc/apache2/apache2.conf

then add the following to the very bottom, then save the file after:

Include /etc/phpmyadmin/apache.conf

d. Restart MySQL server using the command below:

sudo /etc/init.d/apache2 restart

e. Access PHPMyAdmin by launching the browser and typing the address of your Raspberry Pi:
You will see similar screenshot below in the browser:


* Extra:

Add ownership of www directory for FTP upload using the example command:

sudo chown -R loginUserName /var/www

Need a guide on setting up the FTP on Raspberry PI? Check the related topic here

Leave a Reply

Your email address will not be published. Required fields are marked *