So Just What Is A LAMP Stack?
When you come to set up a website on your VPS, you may encounter the need for a LAMP stack on your server within the software requirements. So what is a LAMP stack, and how do you get one?
As you may already have gathered, LAMP has nothing to do with lighting and is all about software. The term itself is an acronym based on the names of the four pieces of software used (listed below), and the word stack is used to refer to a set of software components that work together. Let’s start by looking at the traditional components of the LAMP stack.
L is for Linux
Linux is the operating system that underpins the rest of the software. In general terms of creating the stack, there’s no requirement for any particular distribution of Linux, but distributions which are commonly used when putting a LAMP stack on a server are CentOS, Ubuntu and Debian because these distros offer plenty of guides online to help users.
A is for Apache
The Apache web server is an open-source web server and is the most popular web server on the internet since 1996. It is modular in design with modules available for many extensions you may want to make to your web server, including support to tie into a number of commonly used web programming languages.
M is for MySQL
After Apache, we have MySQL, a database software that has been in use for almost as long as Apache. Again, MySQL is an open-source software, and in recent years a fork called MariaDB has been gaining traction as a seamless replacement for MySQL. MariaDB has been replacing MySQL in many LAMP deployments. MariaDB has also replaced MySQL in a number of Linux distributions, which you should take note of if you are using software that explicitly requires MySQL.
P is for PHP
Finally, we have the PHP programming language. Another open-source project with a similar vintage to both MySQL and Apache, PHP is a programming language created to simplify the creation of dynamic web pages. By dynamic, we mean that the content of the page may be different each time you load it depending on a number of factors. A static file, on the other hand, will be the same every time until somebody edits it.
So how does a LAMP stack work together?
The Apache web server handles incoming requests for web pages from browsers. When they come in, and if the request is for a PHP file, it will pass the request over to PHP which will load the file and then execute the code within the file. Often the code will make reference to data stored in a database which is when PHP will communicate with MySQL to fetch the data or store new data. Using the code in the file and the data from the database, PHP can create the HTML required by the web browser to render the web page. Once PHP completes running the code in the file, it then passes the resultant data across to the Apache web server to send back to the browser. All of this is enabled by the Linux operating system beneath it all on the server.
There are a number of alternatives for the LAMP stack, in some cases, the P may be used to refer to Perl or Python as alternative programming languages. There’s the WAMP stack which makes use of Windows as the operating system instead of Linux, or WIMP which uses Windows and Microsoft’s Internet Information Services web server. LNMP or LEMP are used to refer to using the Nginx (pronounced engine X) web server in place of Apache. There’s also XAMPP which is a tool designed to be cross-platform, hence the X, and can install Apache, MySQL, PHP and Perl on the target system pre-configured and ready to go serving web pages.