Understanding LAMP

by Martin Brown

You've probably heard the acronym LAMP. You may even know what it means. But do you now what the LAMP stack really is and what it does?

If you're at all familiar with open source software, chances are you've heard the phrase "LAMP stack" at some point. You may even know what it stands for. But do you know what LAMP actually is?

The simple answer is LAMP is a Web application development and deployment environment that, although powerful, is also comparatively simple and easy to use. This article will explain what LAMP is, the different components of the LAMP environment, and how, when combined, they create such a powerful environment. We will also look at how LAMP technology can drive Web applications.

Exploding the Acronym

Simply exploding the acronym on a letter by letter basis gives us the following elements:

  • Linux
  • Apache Web server
  • MySQL database
  • Perl, Python, or PHP

Individually, each of these items is a powerful component in its own right. The key to the idea behind LAMP, a term originally coined by Michael Kunze in the German magazine c't in 1998, is the use of these items together. Although not actually designed to work together, these open source software alternatives are readily and freely available. This has lead to them often being used together. In the past few years, their compatibility and use together has grown and been extended. Certain extensions have even been created specifically to improve the cooperation between different components.

Today, the products that make up the LAMP stack are included by default in nearly all Linux distributions, and together they make a powerful web application platform. Figure 1 illiustrates the relationship between the components.

Figure 1
LAMP Relationships

LAMP Relationships

Each of the components in the LAMP stack is an example of Free or Open Source Software (FOSS). The benefit of the FOSS approach is three-fold. First, the nature of FOSS software means applications are available for free download, making them readily available to a wide range of people without payment. That makes the software incredibly attractive to a wide range of users who would otherwise have to pay for "professional" commercial tools, which is often an expensive step in producing a Web site.

Second, FOSS licenses are open and thus have few restrictions on their use and deployment of applications based on the FOSS technology. It is possible to develop and deploy LAMP-based projects without paying any license fees for distributing the software, and this, again, makes it popular for both hobbyists and professionals alike.

Third, and a major reason for the growth and use of FOSS technology (including LAMP), is that because users have access to the source it is much easier to fix faults and improve the applications. In combination with the open license, this simplifies the development process for many enterprises and gives them flexibility that simply isn't available within the confines of a proprietary or commercial-based product.

>> The Components of LAMP


Linux is the operating system on which the applications execute. As an operating system, Linux is obviously capable of acting as much more than a Web application platform, but it has many benefits in this space. Aside from the FOSS approach of Linux, the flexibility of the Linux operating system and how it can be customized means it is fairly easy to produce a highly optimized platform on which to deploy Web applications.

For example, Linux supports a range of different file systems, some of which make more sense for Web serving than otehrs. We can also heavily customize the Linux kernel to tweak the best performance, and years of open source development have produced a wide range of network drivers.

The open source approach of Linux has meant that the operating system has been developed for a wide range of platforms, from desktop PCs to massive servers and mainframe hardware, all the way down to embedded systems. Thus, "old" or unusual hardware that is no longer OEM-supported can now be used to run Linux and to deploy LAMP applications.

Despite all the complexities of the Linux operating system, the distribution model, which packages together different components, means installation and deployment of Linux-based server can be very easy. There are even distributions specially designed to be used when developing and deploying LAMP-based applications, further simplifying the use of LAMP technology.

Apache HTTPD

The Apache project is now a generic name given to a number of high-quality, open-source-based application projects, but its original project was the HTTPD Web server. Apache HTTPD is a powerful Web serving platform that can be used to provide basic file-based serving, which can work with CGI to provide interactive applications or be combined with loadable modules to support a very efficient Web application service.

Apache HTTPD itself is a relatively simple product but a very fast and capable one. Although this description may be seen as slightly unfair considering the flexibility and functionality of the application, the real power of the Apache HTTPD server is its support for loadable extension modules to enhance that base functionality.

Within the standard Apache HTTPD project, these include modules for caching data, providing different authentication and security environments, and supporting a wide range of management functionality, such as Web site traffic. For Web application support, modules enhance the power of the Apache HTTPD by allowing users to embed an interpreter for one of the LAMP languages (Perl, Python, or PHP) into the Apache HTTPD project, significantly increasing the speed with which these applications are executed and therefore improving the responsiveness of the Web application.

Although complex at first, Apache can be easily installed and configured and then largely forgotten about. It is safe, secure, and self-managing, and it needs little attention to keep it running. In general, once the initial configuration has been completed, an Apache installation need never be touched ever again.


The MySQL Relational Database Management System (RDBMS) is another example of a simple but very powerful application. As is the case with Linux and Apache, you can generally install a MySQL server and start using it without having to go through any complex configuration or optimization procedures. In its default configuration, MySQL is a very capable relational database, but serious users can also tweak the settings to gain better performance, functionality, or both, simply by changing the underlying storage engine. The article, MySQL Storage Engines, on LinuxPlanet, discusses the various storage engines available.

Figure 2
MySQL in Action

MySQL in Action

The power of MySQL is that it supports SQL and relational tables, making it much easier to develop enterprise-level databases while using the standard SQL language. Enterprise with small and large databases alike use MySQL. It is particularly efficient with applications that have a comparatively large number of queries and few updates (particularly in its default configuration), and it is therefore well-placed to support dynamic and database-driven apps, such as blogs, stores, and reference databases.

Applications with a high number of transactions use the InnoDB storage engine that is designed to handle the higher level of transactions and does not impose the same locking restrictions that can affect other storage engine types.

Perl, Python, or PHP

The main benefit of all three of the languages in the LAMP stack, Perl, Python and PHP, is that they are "interpreted" languages. Being interpreted, rather than compiled, they are quick and easy to use. There is no need for the application you are writing to be compiled — you just run the application. This speeds up development time and makes it easier to use and learn languages. They all provide a rich environment that makes it easy to perform complex tasks and provide an interface for developers to extend that functionality. When combined, they each make a powerful, but simple, environment for writing applications of all kinds.

Perl, Python, and PHP were originally heavily used during Web development because of the CGI interface built into early Web servers (Apache included, of course). CGI enables the Web server to exchange data between the client's browser and an external application in a defined way. By supporting external, CGI-based applications, Web developers could introduce dynamic elements. Developing compiled applications that used this interface was comparatively complex, but the interpreted languages usually include the functionality, either directly (as with PHP) or through a standard module (as with Perl and Python).

The early Web pioneers mostly used Perl, a flexible language, particularly when dealing with text elements, which made it easy to process the data supplied through the CGI interface and also to manipulate text files and simple databases to support the dynamic elements. The integration of Perl as a dynamic language is further extended through the mod_perl module for Apache. The mod_perl module, among other techniques, embeds the Perl interpreter into the Apache installation, enabling the execution of Perl scripts without the significant overhead that occurs with CGI.

PHP, or Personal Home Pages, was originally a suite of Perl scripts that used the CGI interface to create a dynamic home page for Rasmus Lerdorf. When the PHP environment took off, the language was completely redeveloped as a stand-alone programming language, but it still owes much of the language semantics to the Perl language on which it was based. Where PHP has the edge on Perl is that PHP is a language designed to develop Web applications and is therefore much more logical in use for some programmers. Furthermore, because the PHP code is directly embedded into Web pages, the way the language works and interacts with the HTML is clearer and easier to understand, even for non-programmers. PHP is also often easier to be deployed to a hosting service because you need only supply the PHP pages, not a combination of HTML pages and CGI scripts.

>> The Whole Package

LAMP Is Greater Than the Sum of Its Parts

The Apache server running on Linux is an easy way of building a simple Web server, but the information provided by the Apache server will be "static" — that is, basic pages of information that the you must build and type yourself.

Adding interactive or dynamic components requires the use of a programming language, like Perl or PHP. These allow you to work with forms. For example, they let your users send you an e-mail or randomly select a page to visit.

By combining a Web server (Apache), dynamic components (using Perl, Python, or PHP), and a database (MySQL) we can create a truly database-driven and dynamic Web site that is easy to update and provides rich functionality to support users.

For truly interactive and dynamic Web sites, however, what you need is a way of building pages composed of information in a database. For example, imagine you want to create an online store along the lines of Amazon. You could do it using static pages. You could even use dynamic elements to let people add products to their basket and send their order to you, but as the number of products to be sold increases, the management overhead to control everything will become a nightmare. Furthermore, providing advanced functionality for customers, such as the ability to view past orders, can be impossible.

This is where the power of the LAMP stack shines. By combining a Web server (Apache), dynamic components (using Perl, Python or PHP), and a database (MySQL) we can create a truly database-driven and dynamic Web site that is easy to update and provides rich functionality to support users.

The easiest way to see the power and functionality of the LAMP stack in action is to take a look at some of the pre-packaged applications available that use LAMP technology. A well-known example of this is the WordPress blogging system. WordPress uses PHP to interface with a MySQL database and can be hosted on an Apache/Linux server.

Choosing to use open source for your business is not about cost; it is about the effectiveness and capabilities of the product to do its job.

The WordPress system is powerful and demonstrates most of the functionality of the LAMP system. PHP is the application environment, extracting data from the database and formatting it for display in a Web browser. All of the "articles" or posts are stored in a MySQL database, and individual posts are categorized in the right-hand panel to make it easy to find and locate posts on specific topics. Posts can also be selected by date, and even author, since WordPress also supports multiple users. WordPress can use the relational functionality of MySQL to display posts ordered by category or to display only specific categories. Even in the simple display of the "home" page, it uses the relational features of MySQL to extract relevant data for each post.

Another good example is Wikipedia, which uses PHP, MySQL, and Apache HTTPD to provide an online encyclopedia with thousands of entries in multiple languages. All of this is served by Linux servers running the WikiMedia application.

Figure 3
Wikipedia at Work

Wikipedia at Work

This functionality is possible within other Web application environments, but the key is how simply all of the LAMP components work together. The WordPress code, for example, is surprisingly simple and straightforward. The code is easily customized and extended, and formatting can be altered to meet individual needs.

Using the LAMP Stack in Your Business

Choosing to use LAMP in your business is not about cost — although many enterprsies will be attracted to the low-cost required for both development and deployment. Instead, choosing LAMP for your organization is about the benefits it provides, as summarized below.

  • Flexibility: There are no limits to what you can do with the LAMP stack, either technically or because of licensing restrictions. This allows you the flexibility to build and deploy applications in a method that suits you, not the supplier of the technology you are using.
  • Customization: Because LAMP components are open source, they have built up a huge array of additional components and modules that provide additional functionality. The open source approach enables you to do the same, customizing components and functionality to suit your needs.
  • Ease of Development: You can write powerful applications using LAMP technology in relatively few lines of code. Often the code is straightforward enough that even nonprogrammers can modify or extend the application.
  • Ease of Deployment: With neither licensing issues nor the need to compile applications, deployment is often as easy as copying an application to a new host. Most hosting services provide LAMP-based environments as standard, or they can be deployed using a Linux distribution, such as Fedora or Debian.
  • Security: With many eyes developing the software and years of use by a wide range of users and community groups, LAMP technology is secure and stable. Problems are normally fixed very quickly, and without the need for a costly support contract.
  • Community and Support: A wide and experienced group of people is willing to provide help and support during the development and deployment of LAMP-based applications.

Many successful business have already leveraged the use of LAMP technology. Many heavily trafficked Web sites use LAMP, or components of it, to support their applications.

Related Acronyms

The original LAMP acronym has spawned a number of other, related acronyms that capitalize on the main focus of the original combination of technologies to provide feature rich Web sites. Although many alternatives are out there, the most prominent are the following:

  • LAPP - Linux, Apache, PostGreSQL, Perl/Python/PHP
  • WAMP - Windows, Apache, MySQL, Perl/Python/PHP
  • MAMP - Macintosh, Apache, MySQL, Perl/Python/PHP
  • BAMP - BSD, Apache, MySQL, Perl/Python/PHP
  • WIMP - Windows, IIS, MySQL, Perl/Python/PHP
  • AMP - Which allows the omission of the operating system

      They are all based around similar principles, with the most common item being the languages. To be fair, the operating system is not as important as the server, database, and language options, since AMP is also an effective combination on other platforms, including Windows. It is, however, more common to use an entirely open source solution, and the support that comes with Linux distributions for easily installable versions is an obvious bonus.


      The LAMP stack is basically the combination of four popular open source technologies that together produce a powerful application serving platform. LAMP is often seen as the best open source solution to compete with proprietary and commercial products, such as Windows, IIS, and .NET. Certainly its low cost is appealing, but the open source nature, making for free and easy development and deployment, is a much more attractive reason to use the technology. Choosing to use it for your business is not about cost; it is about the effectiveness and capabilities of the product to do its job.

    • This article was originally published on Thursday Dec 1st 2005
      Mobile Site | Full Site