Javatpoint Logo
Javatpoint Logo

How to Install LAMP (Linux Apache MySQL PHP) on Ubuntu?


LAMP is an acronym that used to refer a software suit, which contains Linux operating stem, Apache web server, MySQL database and PHP programming language.

It is also known as LAMP stack and used to developed dynamic web applications.

It is a group of softwares, so, either we can install all the component softwares independently or as a single unit.

LAMP is short for Linux, Apache, MySQL, PHP/Python/Perl. Sometimes, it is called a LAMP stack due to the platform includes four layers. Stacks can be established on several OSes. Developers that utilize these using a Windows OS rather than Linux OS are said to be utilizing WAMP along with a MAMP, Macintosh system, and with a SAMP, Solaris system.

All components share necessary features to the stack:

  • Linux (operating system): It is an open-source and free operating system that has been accessible since the mid-1990s. It has a wide user base worldwide that extends around industries. Linux OS is famous partly because it provides more configuration and flexibility options than other OSes.
  • Apache (webserver): This web server is used to process several requests and provides web assets through HTTP, so the application is usable by anyone over a general web URL in the public domain. Developed and managed by an open-source community, the web server is a feature-rich and mature server that executes an extensive website share on the internet currently.
  • MySQL (database): MySQL database is an open-source RDBMS (relational database management system) to store app data. We can store every information using MySQL in a way that is simply queried with SQL. SQL is a better choice if we are dealing with any business domain that is well organized, and we wish to convert this structure into a backend. Besides, MySQL is compatible with running even complex and large sites.
  • PHP (programming language): PHP is an open-source scripting language that operates with Apache to support us in creating dynamic web pages. We can't use HTML to implement dynamic processes like pulling information from a database. Simply, we write PHP code into a page's parts that we wish to be dynamic to offer this kind of functionality.

It is developed for efficiency. PHP makes the programming process easier and more fun by permitting us to write fresh code and immediately find the final changes without compilation requirements. If we prefer, we can switch PHP in favor of the increasingly famous Python and Perl language.

PHP includes a standard layered architecture along with Linux at the bottom layer. Nominally, PHP is at the presentation layer or top; the PHP element sits in Apache.

Importance of LAMP

Web developers select LAMP to create web apps for the below reasons:

  • Cost: Every LAMP technology is open source, so any company or developer can utilize them without needing to pay any licensing fee. We can download the OS, scripting language, database, and web server for free rather than buying proprietary stack elements. It lowers the rate of creating web apps.
  • Efficiency: Originating a new web development stack needs rigorous testing of several tools, libraries, modules, and frameworks. Besides, LAMP is a tried-and-tested solution for web development. Web developers can speed up and prioritize application development to concentrate on what they are creating rather than how they're creating it.
  • Maintenance: Worldwide, any software experts contribute to the LAMP stack technology development by modifying, commenting on, and analyzing the source codes publicly available. Regularly, they maintain and renew the technologies so they remain secure and relevant.
  • Flexibility: LAMP provides both flexibility and reliability to web developers. Developers can change them as they find fit, while the architecture of LAMP defines the software elements for all layers. For instance, they can use other operating systems than Linux.
  • Support: Famous open-source technologies, like LAMP, include the support of a global and large IT community. So, LAMP users can more conveniently find material on public IT forums. Several web developers can assign example codes or utilize tested plugins built by the open-source community.

Usage of LAMP

LAMP is used for server-side and backend development. A backend app is software that executes in an environment that is covered from end users. Some backend applications are composed of the below:

  • API to communicate with several other applications
  • Business philosophy in code
  • Database components
  • Data processing applications

The webpage that displays on our browser is known as the front-end application. Our browser negotiates with the backend application to get the required information when we reach out to the page like by clicking on any button.
Developers utilize LAMP to make both dynamic and static web content.

  • Dynamic webpages: They include information that modifies relying on the user viewing the web application or webpage. For instance, a website message that modifies based on our position is dynamic content. Besides, the web server provides dynamic websites by clarifying business philosophy or getting information from a database.
  • Static webpages: From the web server, the information of a static webpage is the same for every user. For instance, the address on the website of a company is static content. Several web developers make static webpages using CSS and HTML programming languages and save them inside the web server application as files.

Working of LAMP

Web applications utilize LAMP to answer requests using web browsers. The MySQL database and Apache web server execute on the Linux OS and communicate with PHP. LAMP goes through the below process when we open any webpage in our browser:

  • Receive requests: The Apache web server accepts incoming requests with the help of the browser. The Apache web server directly responds using the correct content if a request is to download a static file. Apache web server will pass that request to a PHP element when it is for dynamic content. The PHP element finds and downloads the correct PHP file that can implement the request.
  • Process requests: A PHP file includes PHP functions. These functions are codes used to generate dynamic content. A PHP component can process the PHP functions, like building a sales chart or transforming measurement units. A few PHP functions might need data from the database. In these types of situations, the PHP code fetches the saved data from the database and applies it to the function process.
  • Return responses: PHP passes the evaluated results in HTML format to the web server. Also, it stores fresh information in the MySQL database at the same time. The Apache HTTP server transmits the dynamic HTML outputs to the browser of the user.

Alternatives of LAMP

LAMP variants, or LAMP alternatives, are some technologies for backend development that use several components. For instance, many web developers might utilize other web servers rather than Apache to accept and process requests via frontend applications. A few alternatives of LAMP might utilize proprietary components, like licensed OSes.

  • Alternative scripting languages
    Developers can substitute PHP with Python or Perl while it is the scripting language (default) for LAMP.
    • Python: It is a high-level language used to build many types of software, such as web applications. In web development, developers utilize Python as it is easy to understand and simple.
    • Perl: This programming language has been present for 30+ years. For web development, developers utilize Perl as it operates together with database integration and contains many frameworks that support development. These frameworks are some software tools that include well-tested elements that stimulate application development.

LAMP stack and MEAN stack

MEAN stands for MongoDB, Express.js, Angular.js, and Node.js. MEAN is a substitute for LAMP, and it is developed in JavaScript technologies, where JavaScript is a language used for frontend and backend development. Some of the important aspects of MEAN components are as follows:

  • MongoDB database works together with JSON, which is a JavaScript type used to read data.
  • js framework offers open-source tools to develop backend apps.
  • js platform executes JavaScript apps.
  • js open-source framework is used to develop frontend apps.

LAMP stack vs. MEAN stack

LAMP and MEAN are good open-source software stacks for many types of web apps. On the frontend, a MEAN stack is compatible with web apps that involve massive logic processing. Besides, a LAMP stack is good for large-scale complicated websites that manage heavy traffic. For instance, developers utilize a MEAN stack for building a video-streaming web app but select a LAKP stack for the e-commerce web app.

Variants of LAMP

The LAMP stack has been accepted by other componentry, so typically composed of open-source and free software. Retronyms and variations occurred for other combinations of software language, database, web server, and operating system with the increasing use of archetypal LAMP.

Also, the database and web server management systems vary. A version, i.e., LEMP, in which Apache has been substituted with the more delicate Nginx web server. A version in which MySQL has been substituted by PostgreSQL is known as LAPP, or by keeping the actual acronym sometimes, LAMP.

The LAMP stack can be merged with several other open-source and free software packages, such as:

  • Cacti, Collectd, or Nagios, for monitoring.
  • RRDtool used for diagrams.
  • Snort, an IDS (intrusion detection) and IPS (intrusion prevention) system.
  • netsniff-ng for security hardening and testing.

In this tutorial, we will install LAMP on Ubuntu, this installation process includes the following steps.


  • Ubuntu
  • Terminal

LAMP Installation

1) Install

Open terminal, enter this single command, it will install complete LAMP stack into our system. If any package is present, will be skipped but new packages will be installed.

2) MySQL Configuration

During installation, MySQL prompts to configure database credentials. Click OK and proceed.

Software LAMP 1

3) Set Password

MySQL prompts for root password. So, enter password and click OK.

Software LAMP 2

4) Confirm Password

Repeat password to match previous entered password and click Ok.

Software LAMP 3

After setting password, MySQL install its packages and rest of the installation completes successfully.


Now, we will check that all the software has installed successfully or not.


Open terminal, enter following command to login into MySQL.

Software LAMP 4

Well, MySQL monitor is displayed, it means MySQL has installed successfully.


First start apache, access from the browser by entering localhost. Use this command to start Apache.

Software LAMP 5

It shows that Apache is working fine and has installed successfully.


To check PHP, create a info.php file inside /var/www/html directory. The info.php file contains the following code.

Access this file from the browser using localhost/info.php and it will show the following output.

Software LAMP 6

Well, we have set up LAMP stack successfully in our system.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA