LAMP is an acronym that stands for Linux Apache, MySQL/MariaDB and PHP. i have LAMP installation post for PiHome but i see lots and lots of people are looking for setting up php 7 with phpMyAdmin and MariaDB on raspberry pi and there isn’t any comprehensive set of instruction that covers this all for PHP 7, MariaDB on raspberry pi.

If you are looking for Raspberry pi SD card image for LAMP (Apache, PHP 7.0 and MySQL/MariaDB on a Raspberry Pi with phpMyAdmin) pre installed then check out Download section.

Follow OS (Raspbian Jessie) Installation and WiFi Configuration posts to install and get WiFi configured without any screen connected to Raspberry pi.

Note: if you are here for some troubleshoot Raspberry Pi LAMP (PHP 7.0 and MySQL/MariaDB on a Raspberry Pi with phpMyAdmin) then check out troubleshooting post on Raspberry Pi LAMP

Update System

Issue following commands to update your raspberry pi.

Repository Sources for Raspbian Stretch

Modify /etc/apt/sources.list and uncomment stretch sources.

Install Apache Server

Lets install Apache 2 web server on raspberry pi alone with common packages, you can add extra packages as your need.

Raspberry Pi Apache 2 Installation

Raspberry Pi Apache 2 Installation

Now you are test your apache2 installation. In your browser visit the IP address of your raspberry pi, you should see default Debian page.

Apache 2 Installation Testing on Raspberry Pi

Apache 2 Installation Testing on Raspberry Pi

Add New Repository Sources

As to date PHP 7.0 hasn’t added to the official repository sources, so you need to add one which provides the PHP 7.0 packages. You have to determine which version of raspbian you have installed.

After figuring out which version, choose the one for jessie or the one for stretch. Make sure you choose the correct repository for the version of raspbian. Modify /etc/apt/sources.list file, my sources.list files look like this for Raspbian jessie.

Now add some certificates to use the sources we just added with apt-get.

Add Repository Sources for PHP 7

Add Repository Sources for PHP 7

After successfully adding source and certificates now time to update packages list.

Install PHP 7 on Raspberry Pi

We are ready to install PHP 7 along with some common packages that you may need for web application.

Raspberry Pi PHP 7 Installation

Raspberry Pi PHP 7 Installation

Once Php 7 get installed successfully you can test php and Apache installation.

Install MariaDB Server on Raspbian

With the new version of Raspbian MariaDB is now present in the official repositories, To install it, you just need to run the following command

During MariaDB Server installation you will be asked to set password for the MariaDB Administrative root user.

Note: if you don’t get option to enter password for MySQL/MariaDB simply run sudo mysql_secure_installation and enter root credentials for MySQL/MariaDB.

MariaDB Server on Raspberry Pi set password Administrative root user.

MariaDB Server on Raspberry Pi set password Administrative root user.

Confirm password for Administrative root user.

MariaDB Server on Raspberry Pi confirm password Administrative root user.

MariaDB Server on Raspberry Pi confirm password Administrative root user.

Install phpMyAdmin on Pi with PHP 7 and MariaDB Server

phpMyAdmin isn’t required but it will make your life easier if you need to do any troubleshooting for MariaDB/MySQL Database server.

Select apache2 for phpmyadmin installation and hit ok

PhpMyAdmin Raspberry Pi apache2 or lighttpd option

PhpMyAdmin Raspberry Pi apache2 or lighttpd option



Install phpMyAdmin on Pi with PHP 7 and MariaDB Server

Install phpMyAdmin on Pi with PHP 7 and MariaDB Server

phpMyAdmin Password of the Database's administrative user

phpMyAdmin Password of the Database’s administrative user

Configuring phpMyAdmin: MySQL/MariaDB application password for the phpmyadmin

Configuring phpMyAdmin: MySQL/MariaDB application password for the phpmyadmin

Configuring phpMyAdmin: MySQL/MariaDB application password for the phpmyadmin confirmation

Configuring phpMyAdmin: MySQL/MariaDB application password for the phpmyadmin confirmation

Apache Configuration for phpMyAdmin

Configure Apache to work with phpMyAdmin. Edit /etc/apache2/apache2.conf and go to end of file.

Add following line and then CTRL+O to save changes and then CTRL+X to exit.

Now restart Apache web server, if everything was correct Apache service should start successfully.

Now you can test phpmyadmin from your browser http://<pi ip address>/phpmyadmin

phpMyaAmin raspberry pi login page

phpMyaAmin raspberry pi login page

Change Document Root Folder

By default Apache server installed with document root pointing to /var/www/html, you need to change this in /etc/apache2/sites-available/000-default.conf for PiHome to work.

To

Restart Apache Service