Dockerize your LAMP Application in 3 mins

What is a LAMP Application?

J
3 min readApr 4, 2023

LAMP is an acronym for one of the most common software stacks for building web applications.

The acronym stands for:

L – Linux

A – Apache

M – MySQL

P – PHP/Perl/Python

In this article I will build and Dockerize a basic LAMP application.

My LAMP Application

I built a skeleton LAMP application with the following index.php file:

<?php
$db = new PDO('mysql:host=localhost', 'root', null);

function getOSInformation()
{
if (false == function_exists("shell_exec") || false == is_readable("/etc/os-release")) {
return null;
}

$os = shell_exec('cat /etc/os-release');
$listIds = preg_match_all('/.*=/', $os, $matchListIds);
$listIds = $matchListIds[0];

$listVal = preg_match_all('/=.*/', $os, $matchListVal);
$listVal = $matchListVal[0];

array_walk($listIds, function(&$v, $k){
$v = strtolower(str_replace('=', '', $v));
});

array_walk($listVal, function(&$v, $k){
$v = preg_replace('/=|"/', '', $v);
});

return array_combine($listIds, $listVal);
}
$osInfo = getOSInformation();
?>
<!doctype…

--

--

J
J

Written by J

Software Engineer - .NET | MongoDB | Docker | GitLab

No responses yet