# LAMP（软件套件）

LAMP是四种开源软件技术的组合，它们协同工作，用于构建和运行动态网站与Web应用：Linux操作系统、Apache HTTP服务器、MySQL数据库以及[PHP](https://www.edgepedia.org/zh/php)编程语言。这一术语由米夏埃尔·孔策（Michael Kunze）于1998年在德国计算机杂志《c't》上提出，作为一个类似营销名称的提法，指代商业Web平台的自由软件替代方案；此后它已成为使用最广泛的开源Web技术栈之一。<sup>[1](https://prodcs.lwn.net/Articles/189186/)</sup><sup> • </sup><sup>[2](https://aws.amazon.com/what-is/lamp-stack/)</sup>

| 关键事实 | 详情 |
|---|---|
| 组件 | Linux（操作系统）、Apache（Web服务器）、MySQL（数据库）、PHP（编程语言）；四者均为开源<sup>[2](https://aws.amazon.com/what-is/lamp-stack/)</sup> |
| 起源 | 缩略语由米夏埃尔·孔策于1998年在德国杂志《c't》上提出<sup>[1](https://prodcs.lwn.net/Articles/189186/)</sup> |
| 各组件问世时间 | Linux 1991年，Apache 1995年，MySQL 1996年，PHP 1995年<sup>[3](https://cloud.google.com/mysql/lamp)</sup> |
| “P”的含义 | 最初指PHP；实际使用中可代表PHP、Perl或Python中的任意一个<sup>[4](https://reposit.haw-hamburg.de/bitstream/20.500.12738/7994/1/bachelor_thesis.pdf)</sup><sup> • </sup><sup>[3](https://cloud.google.com/mysql/lamp)</sup> |
| 数据库地位 | 据DB-Engines，MySQL是世界上第二受欢迎的数据库<sup>[3](https://cloud.google.com/mysql/lamp)</sup> |
| 典型用途 | 服务器端Web应用及内容管理系统，如WordPress、Drupal和Joomla<sup>[5](https://www.ibm.com/think/topics/lamp-vs-mean)</sup><sup> • </sup><sup>[6](https://interoperable-europe.ec.europa.eu/sites/default/files/document/2012-12/OSSlists1a-flat1.pdf)</sup> |
| 现代PHP部署方式 | 新安装建议使用PHP-FPM配合Apache的mod_proxy_fcgi模块；自httpd 2.4起，event MPM一直是Apache的默认多处理模块<sup>[7](https://www.php.net/manual/en/install.unix.apache2.php)</sup> |

## 术语的起源

米夏埃尔·孔策于1998年在德国计算机杂志《c't》的一篇文章中引入了LAMP这一缩略语。该文旨在说明，一组自由软件可以成为商业软件包切实可行的替代方案；孔策有意选择了一个缩略语，因为他深知IT界对缩略语的偏爱，想借此提升自由软件的知名度。<sup>[1](https://prodcs.lwn.net/Articles/189186/)</sup><sup> • </sup><sup>[4](https://reposit.haw-hamburg.de/bitstream/20.500.12738/7994/1/bachelor_thesis.pdf)</sup>在他最初的用法中，各字母分别代表Linux、Apache、mSQL/MySQL和Perl/PHP。<sup>[8](https://www.marpis.net/lamp-history.php)</sup>奥莱理（O'Reilly）与MySQL AB后来在英语使用者中推广了这一术语，MySQL AB还借该技术栈的流行开展了一些自身的营销。<sup>[8](https://www.marpis.net/lamp-history.php)</sup>

脚本层本身早于这一名称出现。它源于20世纪90年代初的CGI Web接口，这类接口让浏览器能够在Web服务器上执行程序，并接收动态内容与静态内容；脚本语言之所以受青睐，是因为它们易于处理文本流，系统设计者因此称之为胶水语言。<sup>[8](https://www.marpis.net/lamp-history.php)</sup>

## 四个层次

**Linux。** Linux于1991年发布，是自由及开源的操作系统，构成该技术栈的基础；其余三个组件都运行在它之上。由于其源代码开放，组织可以修改它以满足自身需求。<sup>[3](https://cloud.google.com/mysql/lamp)</sup>

**Apache。** Apache HTTP服务器于1995年发布，是第二层。它接收来自浏览器的HTTP请求并提供相关Web内容；其模块化设计催生了一个扩展生态，涵盖身份验证、加密、日志记录及其他功能。<sup>[3](https://cloud.google.com/mysql/lamp)</sup>该服务器的多处理模块（MPM）让管理员可以定制请求的处理方式：需要可扩展性的站点可以使用worker或event之类的线程化MPM，而需要稳定性或与旧软件兼容的站点则可以使用prefork。<sup>[9](https://d.apache.org/docs/current/mpm.html)</sup>

**MySQL。** MySQL于1996年发布，是一个开源关系型数据库，用于存储、管理和查询应用数据，如用户账户、客户记录和销售数据。应用程序通过结构化查询语言（SQL）访问它。<sup>[3](https://cloud.google.com/mysql/lamp)</sup>历史上，MySQL针对读取速度而非功能丰富度进行了优化，这一设计选择适合高流量的LAMP部署。<sup>[6](https://interoperable-europe.ec.europa.eu/sites/default/files/document/2012-12/OSSlists1a-flat1.pdf)</sup>

**PHP。** PHP于1995年发布，是用于生成[动态网页](https://www.edgepedia.org/zh/dynamic-web-page)的脚本语言；开发者将其嵌入HTML中，以显示实时或更新的信息，例如电商网站上的当前库存。随着时间推移，“P”的含义已扩展到包括Perl和Python。<sup>[3](https://cloud.google.com/mysql/lamp)</sup>

## 请求的处理流程

当浏览器请求一个动态页面时，Apache接收请求并将工作交给脚本层，脚本层运行应用的业务逻辑，并向MySQL查询所需数据；结果被组装成一个页面，发回浏览器。该技术栈用于后端（即服务器端）开发，涵盖数据处理、数据库组件、业务逻辑和API，而浏览器中显示的页面则是前端。<sup>[2](https://aws.amazon.com/what-is/lamp-stack/)</sup>

## 开发者为何选择它

主要驱动因素是成本、成熟度和社区。四个组件均无许可费用，这降低了试点和运行Web应用的成本。这些组件已使用近30年，开发者可以依托成熟的实践、代码和工具，而庞大的全球社区则提供文档、经过测试的插件以及定期的维护和安全更新。<sup>[3](https://cloud.google.com/mysql/lamp)</sup><sup> • </sup><sup>[2](https://aws.amazon.com/what-is/lamp-stack/)</sup>该技术栈还具有灵活性：尽管它为每一层指定了组件，开发者仍可替换为其他方案，例如在底层换用不同的操作系统。<sup>[2](https://aws.amazon.com/what-is/lamp-stack/)</sup>

## 变体与替代方案

由于每一层相互独立，该技术栈常被改造。面向JavaScript的MEAN技术栈（MongoDB、Express、Angular、Node.js）是最常见的比较对象。两者并无绝对优劣；IBM的指导意见是，LAMP适合范围较大、以静态为主、流量峰值高且生命周期短的服务器端应用，以及基于[WordPress](https://www.edgepedia.org/zh/wordpress)等内容管理系统构建的站点，而MEAN适合围绕API和微服务等云技术构建、生命周期长且客户端逻辑较多的应用。<sup>[5](https://www.ibm.com/think/topics/lamp-vs-mean)</sup>

## 部署实践

LAMP是主要内容管理系统的基础。WordPress要求PHP 8.3或更高版本、MySQL 8.0或MariaDB 10.11或更高版本、带mod_rewrite模块的Apache或Nginx，以及HTTPS支持；Drupal 12要求PHP 8.5，并支持MySQL 8.0、MariaDB 10.11、[PostgreSQL](https://www.edgepedia.org/zh/postgresql) 18和SQLite 3.45。<sup>[10](https://wordpress.org/about/requirements/?product=service)</sup><sup> • </sup><sup>[11](https://www.drupal.org/about/core/blog/announcing-drupal-1200-platform-requirements)</sup>

具体到PHP层，PHP项目建议新的Apache部署使用PHP-FPM（FastCGI进程管理器）配合mod_proxy_fcgi模块，而不是较早的mod_php嵌入方式。PHP-FPM提供更好的资源管理、进程隔离、独立的PHP重启，并兼容Apache自httpd 2.4以来的默认event MPM；而mod_php除非PHP以线程安全方式编译，否则需要prefork MPM，这限制了并发能力。<sup>[7](https://www.php.net/manual/en/install.unix.apache2.php)</sup>该技术栈的安全指导遵循标准做法：运行官方支持版本页面上列出的PHP分支，将数据库凭据存放在Web根目录之外，并仅授予数据库账户应用所需的权限。<sup>[12](https://cheatsheetseries.owasp.org/cheatsheets/PHP_Configuration_Cheat_Sheet.html)</sup><sup> • </sup><sup>[13](https://cheatsheetseries.owasp.org/cheatsheets/Database_Security_Cheat_Sheet.html)</sup>

云服务商也提供该技术栈的打包方案：谷歌云（Google Cloud）通过其Marketplace提供完整的LAMP部署，并针对数据库层提供托管MySQL服务Cloud SQL for MySQL。<sup>[3](https://cloud.google.com/mysql/lamp)</sup>

## References

1. [The birth of the open source enterprise stack, LWN.net (2005)](https://prodcs.lwn.net/Articles/189186/)
2. [What is a LAMP Stack? AWS](https://aws.amazon.com/what-is/lamp-stack/)
3. [LAMP stack, Google Cloud](https://cloud.google.com/mysql/lamp)
4. [History of L.A.M.P. architecture, bachelor thesis, HAW Hamburg](https://reposit.haw-hamburg.de/bitstream/20.500.12738/7994/1/bachelor_thesis.pdf)
5. [LAMP vs. MEAN: What's the Difference? IBM](https://www.ibm.com/think/topics/lamp-vs-mean)
6. [Open source software list, Interoperable Europe (2012)](https://interoperable-europe.ec.europa.eu/sites/default/files/document/2012-12/OSSlists1a-flat1.pdf)
7. [PHP: Apache httpd 2.x on Unix systems, PHP Manual](https://www.php.net/manual/en/install.unix.apache2.php)
8. [LAMP history, MARPIS Programming](https://www.marpis.net/lamp-history.php)
9. [Multi-Processing Modules (MPMs), Apache HTTP Server 2.4 documentation](https://d.apache.org/docs/current/mpm.html)
10. [Requirements, WordPress.org](https://wordpress.org/about/requirements/?product=service)
11. [Announcing Drupal 12.0.0 platform requirements, Drupal.org](https://www.drupal.org/about/core/blog/announcing-drupal-1200-platform-requirements)
12. [PHP Configuration Cheat Sheet, OWASP](https://cheatsheetseries.owasp.org/cheatsheets/PHP_Configuration_Cheat_Sheet.html)
13. [Database Security Cheat Sheet, OWASP](https://cheatsheetseries.owasp.org/cheatsheets/Database_Security_Cheat_Sheet.html)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Named software products and platforms › Web servers and content platforms

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/lamp-software-bundle

English original: https://www.edgepedia.org/lamp-software-bundle
