A lightweight and customizable Docker-based LAMP (Linux, Apache, MySQL, PHP) stack for web development and testing.
This project provides a Dockerized LAMP environment, enabling developers to quickly set up a local web server with Apache, MySQL, and PHP. It is designed for simplicity, flexibility, and ease of use, making it ideal for developing and testing PHP-based applications.
- Apache: Configured as the web server with support for
.htaccessand mod_rewrite. - MySQL: A stable and secure database server with customizable configurations.
- PHP: Includes the latest stable PHP version with common extensions.
- Docker Compose: Simplifies setup and management of multi-container services.
- Customizable: Easily modify configurations for Apache, MySQL, and PHP.
- Volume Mapping: Persist data and application code across container restarts.
- Lightweight: Optimized for minimal resource usage.
- Docker installed on your system.
- Docker Compose installed.
- Basic knowledge of Docker and web development.
git clone https://github.com/3sus/lamp-docker.git
cd lamp-dockerCopy the example environment file and adjust settings as needed:
cp .env.example .envEdit .env to customize MySQL credentials, ports, or other settings:
# Example .env file
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=myapp
MYSQL_USER=user
MYSQL_PASSWORD=password
APACHE_PORT=80Start the LAMP stack using Docker Compose:
docker-compose up -d- The
-dflag runs containers in detached mode. - Apache will be accessible at
http://localhost:<APACHE_PORT>(default:http://localhost:80). - MySQL will be accessible on the specified port (default:
3306).
Add your PHP application files to the www/ directory. These files are automatically mapped to the Apache web root.
Connect to the MySQL database using a client (e.g., phpMyAdmin, MySQL Workbench) with the credentials defined in .env.
Example connection details:
- Host:
localhostor127.0.0.1 - Port:
3306(or as defined in.env) - User:
user(or as defined in.env) - Password:
password(or as defined in.env)
To stop the running containers:
docker-compose downlamp-docker/
├── docker-compose.yml # Defines Docker services
├── www/ # Web root for your PHP application
├── mysql/ # MySQL data persistence
├── apache/ # Apache configuration files
└── .env.example # Example environment configuration
- Apache: Modify configuration files in
apache/to adjust settings like virtual hosts or.htaccessrules. - PHP: Add PHP extensions or modify
php.iniin theDockerfileor via volume mounts. - MySQL: Adjust MySQL settings in
docker-compose.ymlor.envfor database configuration.
- Port Conflicts: Ensure the specified ports (e.g.,
80,3306) are not in use by other services. - Permissions Issues: Verify that the
www/directory has appropriate read/write permissions. - Logs: Check container logs for debugging:
docker-compose logsContributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature). - Commit your changes (
git commit -m 'Add your feature'). - Push to the branch (
git push origin feature/your-feature). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Built with Docker and Docker Compose.
- Inspired by the need for a simple, reproducible LAMP stack for development.