How to install PHP 7.1, MySQL 5.7, Apache 2.4 in Debian 8 via apt-get | LAMP

What is LAMP?

LAMP stands for Linux + Apache + Mysql + PHP. In this blog post the Coding Cat will show how to install ready to use LAMP with newest versions: Apache 2.4, Mysql 5.7 and PHP 7.1.

Preparation

If you are on vanilla Debian 8, first update and upgrade:

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

 

Install Apache 2.4 on Debian 8

Installing Apache is simple, just run the code:

sudo apt-get install apache2

 

Install PHP 7.1 on Debian 8

By default PHP on Debian 8 is in lower version than 7.1, so we need to add some addresses to the sources:

sudo apt-get -y install apt-transport-https lsb-release ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

Next, we can use apt-get to install PHP with modules we want:

sudo apt-get update && sudo apt-get install php7.1 php7.1-cli php7.1-fpm php7.1-apcu php7.1-apcu-bc php7.1-common php7.1-curl php7.1-intl php7.1-json php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-opcache php7.1-soap php7.1-xml php7.1-xmlrpc php7.1-xsl php7.1-zip php7.1-gd php7.1-imap php7.1-intl php7.1-zip

 

Installing Mysql 5.7 on Debian 8

First we need to install libaio1 package

sudo apt-get install libaio1

Then download deb package from mysql website:

sudo wget http://dev.mysql.com/get/mysql-apt-config_0.8.6-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.6-1_all.deb

When you see this screen below, just use arrows to go to this “Ok” and press enter. This is one of the worst UX the Coding Cat have ever seen..

Mysql installation screen

 

Update and install

sudo apt-get update
sudo apt-get -y install mysql-community-server

Done. Check installed versions.

Now you are all set, check your version of PHP:

php -version

Version of MySQL:

mysql --version

Version of Apache

sudo apache2 -v