Understanding LAMP Page 2
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.
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.
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.