What is a LAMP stack?

Linux, Apache, MySQL, PHP

This is what is behind the acronym LAMP. It means this is a complete environment for computers/servers based on a Linux OS. This environment, also named “stack”, is used to create a web server environment running under Linux OS, with Apache (more details below), PHP for the programmation language, and MySQL for the database(s).

When you buy a server it comes nude. Most of the times you don’t see that it is nude because your hosting provider has already installed the proper environment, especially for a shared server/hosting. But it is like for a computer, you can buy a computer with no OS, no program, nothing installed on it and you will have to install all the programs you’ll need on your own.
A server needs some specific programs to run websites. This LAMP environment is providing all the tools for a server to run websites made with PHP and MySQL (thus a very large number of websites!).

Linux, but also Windows or Mac

This environment for PHP/MySQL is also existing for Windows and Mac OS. Of course they are not named LAMP since the “L” is for Linux, even though people are often using LAMP acronym while they are on Windows or Mac OS. The derivative environment for Windows is named “WAMP” (you know why!) and MAMP for MacOS.

Why isn’t it the same package? Because, as we’ve seen in the previous chapter about Linux, these operating systems don’t work the same way and so the programs must be adapted to each one of them.

What is Apache?

Apache is a HTTP server software. What does this mean? You know the WordWideWeb is using the HTTP protocol. This protocol is a way, a language, to communicate. This way must be interpreted by the server to send the proper information to your browser, a web page for example. Apache, as a HTTP server software, enables your computer or server to communicate with our computers/servers in this web protocol.

Even if Apache is the most used HTTP server program, there are many others.

Apache comes with a package of modules that can be used by your server to activate some functions on your website. For example, if you want to optimize your website for the search engines, you may want to have smart URLs like your-website.com/review-of-the-new-nintendo-console, rather than an URL that contains any keywords like your-website.com/123.html. These two URLs will send to the same page on your website. The difference is that the second one is the basic one, not “reworked” by the server that hosts your website. Apache, with the “rewrite” module, enables to rewrite an URL with the keywords that are useful for you.
There are dozens of modules like this which are integrated in Apache and that save your time, your business, etc. Most of the time you don’t even know that they are used by your server, you just use them because there is this option in your website software. For example, in WordPress, in Settings > Permalinks, you have the option to choose the way the URLs of your website looks like:


WordPress uses the rewrite module of Apache, and this way allows you to have the URLs of your website rewritten, and you were not even aware that this was thanks to an Apache module.

Apache is also managing the configuration of your website. We will see this aspect in more details in the next course. However to understand the basics and why this configuration is needed, you have to know this process when someone opens your website in his/her browser:

  • The user enters your website URL in his/her browser
  • His/her browser sends an http request to the server on which your website is hosted
  • Your server “knows” that it’s Apache which manages these HTTP request
  • Apache takes the request and:
    • “looks” for the configuration of the website which is requested
    • finds the configuration that tells it:
      • where the files of the website are on the server
      • which rules it has to apply to displaying the website
    • based on this configuration, it “says” to the server what it has to send to the browser of your user
  • The server sends back your website to the browser of your user because thanks to Apache it “knows” how to display your website (where your website files are for example)

So now you can understand that Apache creates a configuration file for your website in order to be able to manage the HTTP requests received by the server, and tells the server what it has to do with them. Apache is like an intermediary between the requests sent by a user when he or she tries to reach your server (to ask for your website for example).


As we’ve seen in the first courses about Understanding and Using a CMS, many website “softwares”, or web applications, like WordPress, Joomla, Siberian are using PHP and MySQL. PHP is the script language and MySQL the database engine. PHP is a server side language (we have also seen that in the courses about PHP), that means the server has to translate the PHP code of your website files to render the correct HTML page in your browser, or execute the right action. To do that PHP must be installed on the server in order to be interpreted.

On the other side, the MySQL engine must also be installed on the server in order to store databases on it.

Installing a LAMP environment on your computer

As we have seen already, a server is a computer. Now you understand that a web server is a computer which can handle HTTP requests that are sent by the users (not really the users but the browsers of the users actually). So the question is: How to enable your own computer to handle HTTP requests? Yes you got it, you just have to install Apache (or another web server program, but here we are just talking about Apache) on your computer, and, there you go, your computer becomes a web server!

Why making your computer a web server?

For these simple and good reasons:

  • You just want to test to create a website
  • You want to test a specific web application (as a reminder, an application is a program)
  • You want to train on a specific environment (stack)
  • You want to make your very specific configuration of your web server without being dependent of your hosting provider environment
  • It’s faster for testing, debugging, etc than having everything hosted at your hosting provider
  • etc

You have to know that it’s very common, and very recommended, to first create and test on your computer and then migrate to the web server at your hosting provider.

So now the question is, why would you migrate the website you have created on your computer to the server at your hosting provider while now your computer is a web server? The question is legitimate as you may now think that your computer is a web server that can handle the requests from users on the Internet. Well, it’s not that easy. Remember from the courses about what is a web hosting, that a server must be reachable from the Internet. So it’s not because your computer can now handle HTTP requests that it is also available from the outside, I mean from users on the World Wide Web. In fact, it acts as a web server but it is not open to the world. If you try to reach your computer which is at home while you are outside of your home, you’ll fail. Opening your computer to the world is another process but it’s not the subject here. What is important for us to know is to understand how you can make your computer a web server for your very own use:

  • Opening your browser
  • Asking from your browser to open a website which is stored on your computer
  • Making your computer “understand” the HTTP requests sent by your browser, thanks to Apache
  • Making your computer send the right information to your browser for displaying your website

Installing LAMP

First, the environment you may want to install will depend on the OS your computer is running. Even if I strongly recommend you install Linux on your computer, I don’t want your wife, husband or children to be mad at you because they cannot use their favorite programs anymore! So here is the package you have to download depending on your OS:

  • Linux: no download, we will see the right procedure below.
  • Windows: download WAMP
  • MacOS: download MAMP (you also have a MAMP version for Windows, but let’s use WAMP if you use Windows to avoid confusion)

Installing Apache, MySQL and Php on Linux

If your computer is under Linux OS you don’t have a LAMP package to download and install, but you have to install the other components: Apache, MySQL and PHP.

Open a terminal window and enter these commands depending on the distribution you have installed:

  • First:
  • apt-get update
  • Then, from Ubuntu 16.04:
    sudo apt install apache2 php mysql-server libapache2-mod-php php-mysql
  • or, for older versions of Ubuntu:
  • sudo apt-get install apache2 php5 mysql-server libapache2-mod-php5 php5-mysql
  • Debian 7.x:
  • apt-get install apache2 apache2-mpm-prefork php5 mysql-server phpmyadmin
  • a2enmod php5
  • service apache2 restart
  • Open your browser and enter https://localhost, if you see a page with “It works!” written, that means…it is working!
  • The access to the phpMyAdmin and thus the database management interface is https://localhost/phpmyadmin/

Installing WAMP on Windows

Just double click on the downloaded file and then follow the instructions. More than words, here is a clear video about how to fully install WAMP and especially how to install Visual C++ libraries that are needed for WAMP:

From your WAMP menu you can have a direct access to the “www” folder. That’s the directory you can use to put your website files. That’s the directory which is configured by Apache to resolve the “https://localhost” URL and display your website.

The access to the phpMyAdmin and thus the database management interface is https://localhost/phpmyadmin/

Installing MAMP on MacOS

From the downloaded file just launch the installation. Then from your list of applications, you just have to click on the MAMP folder and then on the MAMP icon to launch MAMP:


Then just start the servers from the MAMP menu window:


When the MAMP page is opening on your browser that means it works.

You can now add your webpage(s) to the folder htdocs which you can open by going to the list of your applications > MAMP > htdocs. Put your webpages here, and access them by entering the following address into your browser:


The access to the phpMyAdmin and thus the database management interface is https://localhost:8888/phpmyadmin/

Now let’s see how to install a WordPress on your computer!