This project contains a minimal LAMP (Linux, Apache, MySQL, PHP/Perl/Python) stack built with Docker Compose. This simple stack enables to easily and convinently develop and run websites locally. There is no more need to go though the pain of setting up and configuring XAMPP or similar tools. Furthermore with Docker, each development environment can be customized and set up depending on the needs and requirements, independently from each other and without affecting the host environment.

The stack consists of three Docker images:

Read more, clone or fork the project at my GitHub repository:


Pipeline status:

Build status

Table of Contents


The .env file contains some environmental variables to configure the LAMP stack.

Project settings:

Port settings:

Apache settings:

MySQL settings:

PhpMyAdmin settings:

Virtual Hosts

The served website can be reached by typing localhost or (if the HOST_APACHE_HTTP_PORT is _not_ set to 80, then localhost:HOST_APACHE_HTTP_PORT or

In oder to make life easier, the virtual host functionality is enabled in the Apache docker container. Therefore, multiple websites with different domain names can be run on a single server. This enables the possibility to reach the served website via a the domain name defined by the COMPOSE_PROJECT_NAME environmental variable. To expose this domain name to the host (who runs the docker containers), the domain name needs to be added to the hosts file:

  1. On MacOS and Linux, open the hosts file (/etc/hosts) with elevated privileges:
    sudo nano /etc/hosts
  2. Add the following entry to a new line:
    ...       lamp
    where lamp is the name of the virtual host.
  3. Save the modifications and the served website now can be reached by simply typing lamp into the browser.

Note: On Windows, the hosts file is located at: c:\Windows\System32\Drivers\etc\hosts.

Serving Multiple Websites

With the help of Virutal Hosts, multiple websites can be served simultaneously.

Steps to serve multiple websites with the same webserver:

  1. Define a new DocumentRoot and server name within the Apache docker container (e.g. with new environmental variables in the docker-compose.yml file):
      SECOND_DOCUMENT_ROOT: /var/www/second
  2. Mount the folder of the additional site to the Apache docker container by adding a new bind mount:
      - path/on/host/to/second/site:${SECOND_DOCUMENT_ROOT}
  3. Edit the config/vhosts/default.conf file and add a new virtual host entry for the additional site:
    <VirtualHost *:80>
        DocumentRoot ${SECOND_DOCUMENT_ROOT}
        <Directory ${SECOND_DOCUMENT_ROOT}>
            AllowOverride all
  4. Add the server name of the additional site to the hosts file:
    ...       second

After restaring the LAMP stack, both sites are available with their respective domain names simultaneously.


Execute the following command (from the folder where the docker-compose.yml file resides) to build the containers and run the LAMP stack in detached mode (run containers in the background):

docker-compose up -d --build

The served website can be accessed from the addresses of localhost and If the virtual host name is exposed to the host (see above), then the website can also be accessed via this domain name.

The phpMyAdmin interface can be accessed via localhost:8080 by default.

To stop the containers and tear down the LAMP stack, execute:

docker-compose down
This removes all created containers and networks defined in the compose file.


A basic GitHub Actions workflow is used to test whether the LAMP stack is operational. The workflow file (.github/workflows/ci.yml) runs automatically on each git push and checks whether the docker containers can be started and the served test website, as well as the phpMyAdmin interface is reachable.