A modern, flexible LAMP (Linux, Apache, MySQL, PHP) development environment built using Docker Compose. Perfect for local development with multiple PHP version support, database management, and email testing capabilities.
- Linux: Alpine/Debian base images
- Apache: HTTP server (2.4+)
- MySQL: Database server (Latest)
- PHP: Multiple version support
- phpMyAdmin: Database management
- Composer: PHP dependency manager
- NodeJS: JavaScript runtime
- MailHog: Email testing tool
| PHP Version | Status | Use Case |
|---|---|---|
| 5.6 | Available | Legacy application support |
| 7.3 | Available | Older projects |
| 7.4 | Available | Mainstream support |
| 8.0 | Available | Modern applications |
| 8.1 | Available | Current applications |
| 8.2 | Available | Current stable version |
| 8.3 | Available | Latest features & performance |
| 8.4 | RC | Release candidate |
- Composer: Latest released version for dependency management
- NodeJS: Latest LTS version for JavaScript/frontend development
- MailHog: Email testing service with web interface
- VIM: Vim Editor with pre-config
- Docker and Docker Compose installed on your system
- Basic knowledge of Docker concepts
- Sudo privileges (for automatic host configuration)
-
Clone this repository
git clone https://github.com/yourusername/docker-lamp.git cd docker-lamp -
Make the run script executable:
chmod +x bin/* -
Choose your PHP version and start the environment:
bin/start.sh 82 # For PHP 8.2
4- Install vim plugins in Normal mode:
vim :PlugInstall
The script will:
- Set up the selected PHP version
- Automatically configure your hosts file (requires sudo permission)
- Start the Docker containers
- Show you the running containers
- Provide access information
The bin/switch.sh script makes it easy to switch between different PHP versions:
bin/switch.sh <php-version>Available PHP version options:
56- PHP 5.673- PHP 7.374- PHP 7.480- PHP 8.081- PHP 8.182- PHP 8.283- PHP 8.384- PHP 8.4 (Release Candidate)
Example:
# Switch to PHP 7.4
bin/switch.sh 74
# Switch to PHP 8.3
bin/switch.sh 83The run script automatically adds localhost.test to your system's hosts file:
/etc/hostson Linux/private/etc/hostson macOS
For Windows users, the script will display instructions for manually adding the host entry.
Place your PHP application files in the html directory. This folder is mapped to the document root of the Apache server.
- Website: https://localhost.test
- phpMyAdmin: http://localhost.test:8080
- MailHog: http://localhost.test:8025
- Host: mysql
- User: root
- Password: defined in docker-compose.yml
The environment includes MailHog for email testing with the following configuration:
SMTP_HOST: mailhog
SMTP_PORT: 1025
All emails sent by your application will be captured by MailHog and can be viewed at http://localhost.test:8025.
Access the Apache container's command line:
docker exec -it mydev-lamp_apache_1 bashCommon operations:
# Run Composer
composer install
# Run Node commands
npm install
# PHP version check
php -vView container logs:
# All containers
docker compose logs
# Specific container
docker compose logs apache# Stop without removing containers
docker compose stop
# Stop and remove containers
docker compose down
# Stop and remove containers, networks, volumes, and images
docker compose down -v --rmi all-
Sudo password prompt - When running the script for the first time, you'll be prompted for your sudo password to update the hosts file. This is normal and required for host configuration.
-
Port conflicts: If you see errors about ports being in use, check if you have other services running on ports 80, 443, 3306, 8080, or 8025.
-
Permission issues: If you encounter permission problems with the html directory, try:
chmod -R 755 html
-
Windows users: If using Windows, you'll need to manually add the host entry to your hosts file located at
C:\Windows\System32\drivers\etc\hosts.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Docker team for excellent container technology
- PHP community for continued language development
- Apache Software Foundation
- MySQL team