Step 1 – Prerequisites

Login to your Debian 9 server using sudo privileges or root user on the command line. After login to your Debian system upgrade the current packages to the latest available version. Also, install the below packages on your system required for commands next in this tutorial.

Step 2 – Install Apache2

The Debian 9 base repositories contain Apache 2.4 packages. You can simply install Apache2 packages by running the following commands on your Debian 9 system.

Step 3 – Install MySQL

Debian 9 base repository contains MariaDB (Replacement of MySQL) as default database server. If you are okay to go with MariaDB execute commands to install else follow MySQL server installation tutorial.

Step 4 – Install PHP

Default Debian 9 system repositories contain an older PHP version. To install the latest PHP version add a third-party PPA to your system. Run the below command to add PPA to your system. Then install the latest PHP version on Debian 9.

Step 5 – Verify Setup

To verify the LAMP setup on Debian 9, Create a PHP script with phpinfo() function under Apache document root. To do this, edit /var/www/html/info.php file in your favorite text editor and add below content to the file and save it.

Now access the info.php file in the web browser using your system IP address.

HHow To Install LAMP  Apache  MySQL  PHP  on Debian 9 - 84