An open API service indexing awesome lists of open source software.

https://github.com/marcoascosta/docker-lamp-stack

A versatile LAMP stack (Linux, Apache, MariaDB, PHP) built with Docker on Ubuntu 24.04 LTS, supporting PHP versions 7.4, 8.0, 8.1, and 8.3. Includes Redis, Composer, Node.js, phpMyAdmin, and Adminer for a complete web development environment. Organized in version-specific folders, this project is ideal for developers needing a flexible, containeriz
https://github.com/marcoascosta/docker-lamp-stack

adminer apache composer containerization developer-tools devops docker lamp lamp-server lamp-stack mariadb nodejs php phpmyadmin python redis ubuntu web-development webserver

Last synced: 26 days ago
JSON representation

A versatile LAMP stack (Linux, Apache, MariaDB, PHP) built with Docker on Ubuntu 24.04 LTS, supporting PHP versions 7.4, 8.0, 8.1, and 8.3. Includes Redis, Composer, Node.js, phpMyAdmin, and Adminer for a complete web development environment. Organized in version-specific folders, this project is ideal for developers needing a flexible, containeriz

Awesome Lists containing this project

README

        

# Docker LAMP Stack

This repository contains multiple `Dockerfile` configurations for a LAMP (Linux, Apache, MySQL/MariaDB, PHP) stack based on **Ubuntu 24.04 LTS**, with support for different PHP versions: **7.4**, **8.0**, **8.1**, and **8.3**. Each version is organized in its own folder and includes a robust development and production-ready environment with additional tools like Redis, Composer, Node.js, phpMyAdmin, and Adminer.

## Features

- **Base OS**: Ubuntu 24.04 LTS (Noble Numbat)
- **Web Server**: Apache 2.4
- **PHP Versions**: 7.4, 8.0, 8.1, 8.3 (via Ondrej's PPA)
- **Database**: MariaDB
- **Caching**: Redis
- **Tools**: Composer, Node.js 18.x, Python 3, phpMyAdmin 5.1.1, Adminer
- **PHP Configuration**:
- `upload_max_filesize`: 1024M
- `post_max_size`: 1024M
- `memory_limit`: 1024M
- `max_execution_time`: 600 seconds
- `max_input_time`: 600 seconds
- `max_input_vars`: 1000
- `short_open_tag`: On
- **Volumes**: Persistent storage for `/var/lib/mysql`, `/app`, and `/var/lib/redis`
- **Ports**: 80 (Apache), 3306 (MariaDB), 6379 (Redis)

## Prerequisites

- **Docker**: Installed on your system (version 20.10 or higher recommended).
- **Git**: To clone this repository.

## Directory Structure

- `php74/Dockerfile`: Dockerfile for PHP 7.4
- `php80/Dockerfile`: Dockerfile for PHP 8.0
- `php81/Dockerfile`: Dockerfile for PHP 8.1
- `php83/Dockerfile`: Dockerfile for PHP 8.3
- `README.md`: This file
- `LICENSE`: MIT License

## Getting Started

### Clone the Repository

```bash
git clone https://github.com/marcoascosta/docker-lamp-stack.git
cd docker-lamp-stack

Build and Run a Specific PHP Version

For each PHP version, navigate to its folder and follow these steps:
PHP 7.4
bash
cd php74
docker build -t dockerlamp:php7.4 .
docker run --name dockerlamp-7.4 -p 8080:80 -p 3306:3306 -p 6379:6379 -v ./app:/app -v ./mysql:/var/lib/mysql dockerlamp:php7.4
cd ..
PHP 8.0
bash
cd php80
docker build -t dockerlamp:php8.0 .
docker run --name dockerlamp-8.0 -p 8080:80 -p 3306:3306 -p 6379:6379 -v ./app:/app -v ./mysql:/var/lib/mysql dockerlamp:php8.0
cd ..
PHP 8.1
bash
cd php81
docker build -t dockerlamp:php8.1 .
docker run --name dockerlamp-8.1 -p 8080:80 -p 3306:3306 -p 6379:6379 -v ./app:/app -v ./mysql:/var/lib/mysql dockerlamp:php8.1
cd ..
PHP 8.3
bash
cd php83
docker build -t dockerlamp:php8.3 .
docker run --name dockerlamp-8.3 -p 8080:80 -p 3306:3306 -p 6379:6379 -v ./app:/app -v ./mysql:/var/lib/mysql dockerlamp:php8.3
cd ..

Notes:

Use unique container names or stop/remove previous containers to avoid port conflicts.
The -v ./app:/app and -v ./mysql:/var/lib/mysql options mount local directories for persistence. Create these directories in the root of the repository if needed.

Access the Services

Web Server: http://localhost:8080
phpMyAdmin: http://localhost:8080/phpmyadmin (Username: root, Password: root)
Adminer: http://localhost:8080/adminer.php
MariaDB: Connect via localhost:3306 (Username: root, Password: root)
Redis: Connect via localhost:6379

Verify PHP Configuration

To check the PHP version and settings:
bash
docker exec -it dockerlamp-8.3 php -v
docker exec -it dockerlamp-8.3 php -i | grep -E "memory_limit|max_execution_time|max_input_time|max_input_vars"

Expected output for PHP 8.3 (similar for other versions):
text
PHP 8.3.x ...
memory_limit => 1024M => 1024M
max_execution_time => 600 => 600
max_input_time => 600 => 600
max_input_vars => 1000 => 1000
Customization

PHP Extensions: Add more extensions by modifying the apt-get install line in the desired Dockerfile.
Ports: Change the port mappings in the docker run command as needed (e.g., -p 8081:80).
Security: For production, replace hardcoded credentials (root/root) with environment variables or Docker secrets.

PHP Version Support

PHP 7.4: End of life (November 2022). Use for legacy applications only.
PHP 8.0: Security support ended November 2023, extended by Ondrej's PPA.
PHP 8.1: Active support until November 2024, security until November 2025.
PHP 8.3: Latest stable (as of November 2023), active support until November 2025, security until November 2026.

For new projects, PHP 8.3 is recommended.
Troubleshooting

Port Conflicts: Ensure no other services are using ports 8080, 3306, or 6379. Adjust mappings if necessary.
Build Errors: Verify internet connectivity and that the Ondrej PPA is accessible.
Permissions: Ensure the ./app and ./mysql directories exist and are writable on the host.

Contributing

Feel free to fork this repository, submit issues, or create pull requests to improve the stack or add features.
License

This project is licensed under the MIT License. See the file for details.
text

---

### **MIT License File (`LICENSE`)**
(Already provided, but here it is again for completeness):

MIT License

Copyright (c) 2025 Marco Costa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.