LAMP

Definition

LAMP is an acronym for Linux Apache MySQL PHP. It is a high performance platform for serving dynamic and persistent web pages. It is also known as WAMP (when it is run on Windows).

Components

Apache

Apache is a web server. It's standard behaviour is to serve static web pages. There are many plugins/modules which allow it to serve dynamic pages.

MySQL

MySQL is a database server. You can think of it as Microsoft Access without the GUI, but with many more advanced features. A more reasonable comparison would be to Oracle, Sybase, etc.

PHP

PHP is the “Hypertext Preproccessor”. In provides the dynamics of the LAMP platform. PHP pages are designed with a simple programming language somewhat similiar to ASP and C (although far simpler than C). PHP is an apache module.

How Does It Work?

Typically, web pages are designed using HTML. Sections of code are enclosed and seperated by tags. For instance, the <body> tag is where you would put anything that you want to display to screen. Here is an example web page:

<html>
  <body>
    Hello World!
  </body>
</html>


The output of the previous page would look like this:

Hello World!


To add dynamics to this page we would use PHP. Here's a short example that replaces world with someone's name:

<?php
  $name = 'John';
?>
 
<html>
  <body>
    Hello <?php print $name; ?>
  <body>
</html>


PHP code is seperate by special tags that mark when the PHP begins and ends. The front tag is <?php and the end tag is ?>. Anything inbetween these tags are parsed by the PHP module. The above code would look something like this:

Hello John


So, let's add some MySQL into the our example. The following example will search the database for names of people that are age 60. As long as John is the only person that meets this criteria, we will see the exact same results as the above example without MySQL. For brevity some of the function parameters were excluded from the example.

<?php
  // Connect to the database.
  $database = mysql_connect();
  // Create a query using SQL.
  $query = "SELECT name FROM mydatabase WHERE age='60'";
  // Run the query, and store the result in a variable.
  $name = mysql_query($query);
 
// Display the result to the browser.
 
<html>
  <body>
    Hello <?php print $name; ?>
  </body>
</html>


As you can see, the only thing different about the code is the way that we got the data. In the previous example we assigned name manually, but in this one we retrieved it from the database.

How Do I Get Started?

Most Linux distributions include all of the pieces required to immediatly get started developing with the LAMP platform. For Windows, there are several packages that will install all of the required components in one easy step. Just search google for LAMP or WAMP.

References

 
what_is_lamp.txt · Last modified: 2005/06/01 11:52 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki