docker-compose-lamp

docker-compose-lamp

Docker Compose构建的LAMP开发环境

项目采用Docker Compose搭建LAMP开发环境,包含PHP、Apache、MySQL、phpMyAdmin和Redis。支持多个PHP版本,便于本地开发。提供简便的安装过程和可定制的配置选项,允许开发者自定义PHP设置、Apache虚拟主机和数据库版本。集成Xdebug调试和SSL配置,满足开发者需求。

LAMP stackDocker ComposePHPApacheMySQLGithub开源项目

LAMP stack built with Docker Compose

Landing Page

A basic LAMP stack environment built using Docker Compose. It consists of the following:

  • PHP
  • Apache
  • MySQL
  • phpMyAdmin
  • Redis

As of now, we have several different PHP versions. Use appropriate php version as needed:

  • 5.4.x
  • 5.6.x
  • 7.1.x
  • 7.2.x
  • 7.3.x
  • 7.4.x
  • 8.0.x
  • 8.1.x
  • 8.2.x
  • 8.3.x

Installation

  • Clone this repository on your local computer
  • configure .env as needed
  • Run the docker compose up -d.
git clone https://github.com/sprintcube/docker-compose-lamp.git cd docker-compose-lamp/ cp sample.env .env // modify sample.env as needed docker compose up -d // visit localhost

Your LAMP stack is now ready!! You can access it via http://localhost.

Configuration and Usage

General Information

This Docker Stack is build for local development and not for production usage.

Configuration

This package comes with default configuration options. You can modify them by creating .env file in your root directory. To make it easy, just copy the content from sample.env file and update the environment variable values as per your need.

Configuration Variables

There are following configuration variables available and you can customize them by overwritting in your own .env file.


PHP


PHPVERSION Is used to specify which PHP Version you want to use. Defaults always to latest PHP Version.

PHP_INI Define your custom php.ini modification to meet your requirments.


Apache


DOCUMENT_ROOT

It is a document root for Apache server. The default value for this is ./www. All your sites will go here and will be synced automatically.

APACHE_DOCUMENT_ROOT

Apache config file value. The default value for this is /var/www/html.

VHOSTS_DIR

This is for virtual hosts. The default value for this is ./config/vhosts. You can place your virtual hosts conf files here.

Make sure you add an entry to your system's hosts file for each virtual host.

APACHE_LOG_DIR

This will be used to store Apache logs. The default value for this is ./logs/apache2.


Database


For Apple Silicon Users: Please select Mariadb as Database. Oracle doesn't build their SQL Containers for the arm Architecture

DATABASE

Define which MySQL or MariaDB Version you would like to use.

MYSQL_INITDB_DIR

When a container is started for the first time files in this directory with the extensions .sh, .sql, .sql.gz and .sql.xz will be executed in alphabetical order. .sh files without file execute permission are sourced rather than executed. The default value for this is ./config/initdb.

MYSQL_DATA_DIR

This is MySQL data directory. The default value for this is ./data/mysql. All your MySQL data files will be stored here.

MYSQL_LOG_DIR

This will be used to store Apache logs. The default value for this is ./logs/mysql.

Web Server

Apache is configured to run on port 80. So, you can access it via http://localhost.

Apache Modules

By default following modules are enabled.

  • rewrite
  • headers

If you want to enable more modules, just update ./bin/phpX/Dockerfile. You can also generate a PR and we will merge if seems good for general purpose. You have to rebuild the docker image by running docker compose build and restart the docker containers.

Connect via SSH

You can connect to web server using docker compose exec command to perform various operation on it. Use below command to login to container via ssh.

docker compose exec webserver bash

PHP

The installed version of php depends on your .envfile.

Extensions

By default following extensions are installed. May differ for PHP Versions <7.x.x

  • mysqli
  • pdo_sqlite
  • pdo_mysql
  • mbstring
  • zip
  • intl
  • mcrypt
  • curl
  • json
  • iconv
  • xml
  • xmlrpc
  • gd

If you want to install more extension, just update ./bin/webserver/Dockerfile. You can also generate a PR and we will merge if it seems good for general purpose. You have to rebuild the docker image by running docker compose build and restart the docker containers.

phpMyAdmin

phpMyAdmin is configured to run on port 8080. Use following default credentials.

http://localhost:8080/
username: root
password: tiger

Xdebug

Xdebug comes installed by default and it's version depends on the PHP version chosen in the ".env" file.

Xdebug versions:

PHP <= 7.3: Xdebug 2.X.X

PHP >= 7.4: Xdebug 3.X.X

To use Xdebug you need to enable the settings in the ./config/php/php.ini file according to the chosen version PHP.

Example:

# Xdebug 2
#xdebug.remote_enable=1
#xdebug.remote_autostart=1
#xdebug.remote_connect_back=1
#xdebug.remote_host = host.docker.internal
#xdebug.remote_port=9000

# Xdebug 3
#xdebug.mode=debug
#xdebug.start_with_request=yes
#xdebug.client_host=host.docker.internal
#xdebug.client_port=9003
#xdebug.idekey=VSCODE

Xdebug VS Code: you have to install the Xdebug extension "PHP Debug". After installed, go to Debug and create the launch file so that your IDE can listen and work properly.

Example:

VERY IMPORTANT: the pathMappings depends on how you have opened the folder in VS Code. Each folder has your own configurations launch, that you can view in .vscode/launch.json

{ "version": "0.2.0", "configurations": [ { "name": "Listen for Xdebug", "type": "php", "request": "launch", // "port": 9000, // Xdebug 2 "port": 9003, // Xdebug 3 "pathMappings": { // "/var/www/html": "${workspaceFolder}/www" // if you have opened VSCODE in root folder "/var/www/html": "${workspaceFolder}" // if you have opened VSCODE in ./www folder } } ] }

Now, make a breakpoint and run debug.

Tip! After theses configurations, you may need to restart container.

Redis

It comes with Redis. It runs on default port 6379.

SSL (HTTPS)

Support for https domains is built-in but disabled by default. There are 3 ways you can enable and configure SSL; https on localhost being the easiest. If you are trying to recreating a testing environment as close as possible to a production environment, any domain name can be supported with more configuration.

Notice: For every non-localhost domain name you wish to use https on, you will need to modify your computers hosts file and point the domain name to 127.0.0.1. If you fail to do this SSL will not work and you will be routed to the internet every time you try to visit that domain name locally.

1) HTTPS on Localhost

To enable https on localhost (https://localhost) you will need to:

  1. Use a tool like mkcert to create an SSL certificate for localhost:
    • With mkcert, in the terminal run mkcert localhost 127.0.0.1 ::1.
    • Rename the files that were generated cert.pem and cert-key.pem respectively.
    • Move these files into your docker setup by placing them in config/ssl directory.
  2. Uncomment the 443 vhost in config/vhosts/default.conf.

Done. Now any time you turn on your LAMP container https will work on localhost.

2) HTTPS on many Domains with a Single Certificate

If you would like to use normal domain names for local testing, and need https support, the simplest solution is an SSL certificate that covers all the domain names:

  1. Use a tool like mkcert to create an SSL certificate that covers all the domain names you want:
    • With mkcert, in the terminal run mkcert example.com "*.example.org" myapp.dev localhost 127.0.0.1 ::1 where you replace all the domain names and IP addresses to the ones you wish to support.
    • Rename the files that were generated cert.pem and cert-key.pem respectively.
    • Move these files into your docker setup by placing them in config/ssl directory.
  2. Uncomment the 443 vhost in config/vhosts/default.conf.

Done. Since you combined all the domain names into a single certificate, the vhost file will support your setup without needing to modify it further. You could add domain specific rules if you wish however. Now any time you turn on your LAMP container https will work on all the domains you specified.

3) HTTPS on many Domain with Multiple Certificates

If you would like your local testing environment to exactly match your production, and need https support, you could create an SSL certificate for every domain you wish to support:

  1. Use a tool like mkcert to create an SSL certificate that covers the domain name you want:
    • With mkcert, in the terminal run mkcert [your-domain-name(s)-here] replacing the bracket part with your domain name.
    • Rename the files that were generated to something unique like [name]-cert.pem and [name]-cert-key.pem replacing the bracket part with a unique name.
    • Move these files into your docker setup by placing them in config/ssl directory.
  2. Using the 443 example from the vhost file (config/vhosts/default.conf), make new rules that match your domain name and certificate file names.

Done. The LAMP container will auto pull in any SSL certificates in config/ssl when it starts. As long as you configure the vhosts file correctly and place the SSL certificates in config/ssl, any time you turn on your LAMP container https will work on your specified domains.

Contributing

We are happy if you want to create a pull request or help people with their issues. If you want to create a PR, please remember that this stack is not built for production usage, and changes should be good for general purpose and not overspecialized.

Please note that we simplified the project structure from several branches for each php version, to one centralized master branch. Please create your PR against master branch.

Thank you!

Why you shouldn't use this stack unmodified in production

We want to empower developers to quickly create creative Applications. Therefore we are providing an easy to set up a local development environment for several different Frameworks and PHP Versions. In Production you should modify at a minimum the following subjects:

  • php handler: mod_php=> php-fpm
  • secure mysql users with proper source IP limitations

编辑推荐精选

酷表ChatExcel

酷表ChatExcel

大模型驱动的Excel数据处理工具

基于大模型交互的表格处理系统,允许用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。

AI工具酷表ChatExcelAI智能客服AI营销产品使用教程
DeepEP

DeepEP

DeepSeek开源的专家并行通信优化框架

DeepEP是一个专为大规模分布式计算设计的通信库,重点解决专家并行模式中的通信瓶颈问题。其核心架构采用分层拓扑感知技术,能够自动识别节点间物理连接关系,优化数据传输路径。通过实现动态路由选择与负载均衡机制,系统在千卡级计算集群中维持稳定的低延迟特性,同时兼容主流深度学习框架的通信接口。

DeepSeek

DeepSeek

全球领先开源大模型,高效智能助手

DeepSeek是一家幻方量化创办的专注于通用人工智能的中国科技公司,主攻大模型研发与应用。DeepSeek-R1是开源的推理模型,擅长处理复杂任务且可免费商用。

问小白

问小白

DeepSeek R1 满血模型上线

问小白是一个基于 DeepSeek R1 模型的智能对话平台,专为用户提供高效、贴心的对话体验。实时在线,支持深度思考和联网搜索。免费不限次数,帮用户写作、创作、分析和规划,各种任务随时完成!

AI主流办公工具有哪些办公热门AI 助手
KnowS

KnowS

AI医学搜索引擎 整合4000万+实时更新的全球医学文献

医学领域专用搜索引擎整合4000万+实时更新的全球医学文献,通过自主研发AI模型实现精准知识检索。系统每日更新指南、中英文文献及会议资料,搜索准确率较传统工具提升80%,同时将大模型幻觉率控制在8%以下。支持临床建议生成、文献深度解析、学术报告制作等全流程科研辅助,典型用户反馈显示每周可节省医疗工作者70%时间。

Windsurf Wave 3

Windsurf Wave 3

Windsurf Editor推出第三次重大更新Wave 3

新增模型上下文协议支持与智能编辑功能。本次更新包含五项核心改进:支持接入MCP协议扩展工具生态,Tab键智能跳转提升编码效率,Turbo模式实现自动化终端操作,图片拖拽功能优化多模态交互,以及面向付费用户的个性化图标定制。系统同步集成DeepSeek、Gemini等新模型,并通过信用点数机制实现差异化的资源调配。

AI IDE
腾讯元宝

腾讯元宝

腾讯自研的混元大模型AI助手

腾讯元宝是腾讯基于自研的混元大模型推出的一款多功能AI应用,旨在通过人工智能技术提升用户在写作、绘画、翻译、编程、搜索、阅读总结等多个领域的工作与生活效率。

AI助手AI对话AI工具腾讯元宝智能体热门 AI 办公助手
Grok3

Grok3

埃隆·马斯克旗下的人工智能公司 xAI 推出的第三代大规模语言模型

Grok3 是由埃隆·马斯克旗下的人工智能公司 xAI 推出的第三代大规模语言模型,常被马斯克称为“地球上最聪明的 AI”。它不仅是在前代产品 Grok 1 和 Grok 2 基础上的一次飞跃,还在多个关键技术上实现了创新突破。

OmniParser

OmniParser

帮助AI理解电脑屏幕 纯视觉GUI元素的自动化解析方案

开源工具通过计算机视觉技术实现图形界面元素的智能识别与结构化处理,支持自动化测试脚本生成和辅助功能开发。项目采用模块化设计,提供API接口与多种输出格式,适用于跨平台应用场景。核心算法优化了元素定位精度,在动态界面和复杂布局场景下保持稳定解析能力。

OmniParser界面解析交互区域检测Github开源项目
流畅阅读

流畅阅读

AI网页翻译插件 双语阅读工具,还原母语级体验

流畅阅读是一款浏览器翻译插件,通过上下文智能分析提升翻译准确性,支持中英双语对照显示。集成多翻译引擎接口,允许用户自定义翻译规则和快捷键配置,操作数据全部存储在本地设备保障隐私安全。兼容Chrome、Edge、Firefox等主流浏览器,基于GPL-3.0开源协议开发,提供持续的功能迭代和社区支持。

AI翻译AI翻译引擎AI翻译工具
下拉加载更多