en
  English
Phone :  +370 (5) 204-1903
Email: sales@1gbits.com

How to Install Linux, Apache, MySQL and PHP on Ubuntu 16.04

Installing LAMP (Linux, Apache, MySQL, PHP/Perl/Python) on Ubuntu 16.04 Server is a popular and usual process. It has gained popularity over the last few years as a popular web development platform and is among the first open-source software stacks. Even some of the most popular open-source web applications, like WordPress, Joomla, and Drupal run on LAMP.

Linux Tutorials Mar 02, 21 by Nisal N 7 min Read
How to Install Linux, Apache, MySQL and PHP on Ubuntu 16.04

Along with being robust and flexible, it is comparatively easy to use as well. Although not actually built to work together, these open-source software alternatives are readily and freely available. Therefore, this is one of the best reasons to often use them together.  LAMP is an acronym for the following programs:

  • Linux -> The operating system
  • Apache -> The HTTP Server
  • MySQL -> The database management system
  • PHP -> The programming language

To get started with LAMP successfully on Ubuntu 14.04, you need to install each of the 4 technologies and make certain configurations. Therefore, this blog will help you to execute the step-by-step commands for installing the LAMP stack. But before proceeding, let’s learn about LAMP in detail.

What is LAMP (Linux, Apache, MySQL, PHP)?

Known among the best free and open-source approaches to back end development, the LAMP stack is used to build high-performance web applications. Each of its elements contributes to the entire capability of this stack:

1.    Linux:

Linux is free to use an operating system that is widely used by developers around the globe because of its high flexibility and unlimited configuration options. It is the backbone of the LAMP stack because other parts of the same run over it.

It is highly compatible with the programming language and database management used for development in LAMP i.e. PHP and MySQL. This makes the stack even more powerful and easy to use.

2.    Apache HTTP Server:

Apache is the most widely used server in the world. It processes the requests and serves up web assets via HTTP that makes the application accessible to anyone in the public domain via a web URL.

Serving more than half the websites over the internet, Apache has a wide feature-rich ecosystem developed and maintained by the open Apache Software Foundation community.

3.    MySQL:

It is an open-source database management system that efficiently stores application data. MySQL empowers users to store all their information in a format that can be accessed easily with the help of the SQL language.

MySQL is suitable for running large and complex websites and works extremely well with a structured business domain. Therefore, MySQL is best-suited if you change the content of your website quite often and have a lot of user-contributed content.

4.    PHP:

PHP (Hypertext Processor) is a programming language that plays an important role in combining other elements of the LAMP stack. This scripting language works with Apache to build dynamic webpages efficiently.

The popular web scripting language pulls the data out of a database that can’t be performed by HTML alone. To bring this functionality into action, a user just has to integrate the PHP code into the parts of a page that needs to be dynamic.

Benefits of using the LAMP stack

  • Flexibility: You’ll never be bounded if you’re using the LAMP stack. You’ll be liberated with the flexibility to build and deploy applications in your way, not on the basis of the technology you are using.
  • Security: With many years of work done on developing the software, LAMP technology is extremely secure and stable. Since it is backed by a big community, most of the usual problems are normally fixed very quickly.
  • Development: Write powerful, straightforward code and build dynamic applications that can be modified or extended even by non-programmers.
  • Customization: Because all the components are open-source, LAMP is tailored with a galore of extra components and modules that provide additional functionality. This allows customizing components and functionality to accommodate your needs.
  • Community and Support: To help users from getting perplexed, a wide, mushrooming, and experienced group of experts is available to help and support during the development and deployment of LAMP-based applications.

Steps to Install Apache HTTP Server, MySQL, and PHP on Ubuntu 16.04

Follow the steps mentioned below to install Apache, MySQL, and PHP on Ubuntu 16.04. Make sure that you have sudo access before running these commands.

1.    Update the package server

Ensure to update your package server first, then proceed towards installation processes. Use the command for updating.

sudo apt-get update

2.    Install Apache

Install Apache by running the command:

sudo apt-get install apache2

Right after this, a line will pop-up which states “Do you want to continue? [Y/n]”. Type y to proceed further.

Now run the following command to start the Apache services to run.

sudo systemctl start apache2.service

3.    Install MySQL

Installing MySQL is quite similar to the previous step. The only thing that changed is the command:

sudo apt-get install mysql-server

Type “y” to proceed further.

Right after this, you’ll be asked to create a password for MySQL administrative root user. Enter your desired password and hit enter.

4.    Install PHP

To install PHP, run the following command on the terminal. And type “y” to proceed further.

sudo apt-get install php

5.    Starting on boot

To start your web environment on boot, you need to execute the commands below:

sudo systemctl enable apache2.service

sudo systemctl enable mysql.service

 

6.    Restart Services

After installing all the components of the LAMP stack, it’s time to restart MySQL and Apache services to reload any changes done manually. Run the following commands to restart:

sudo systemctl restart apache2.service

sudo systemctl restart mysql.service

The Aftermath

Now your process will run in the following fashion:

  • Apache webserver will receive the requests from the browser. That may be processed further to PHP if the request is for the PHP file.
  • After that, PHP communicates with MySQL to fetch any data referenced in the code.
  • That code in the file and the data from the database will be used to create the HTML that browsers require to display web pages.
  • This resulting data is then transferred back to the Apache webserver to send to the browser.

All of these operations are executed on a Linux - in this case, Ubuntu - operating system which is the core of the stack. Your immediate next step should ensure that connections to your web server are secured, by serving them via HTTPS.

Conclusion

Following the aforementioned steps will enable you to take advantage of LAMP for building powerful apps and websites.

LAMP is not just efficient at handling only static web pages but also dynamic pages where the content may change each time depending upon the user, date, time, identity, and other factors. You can get a Linux VPS and start taking full advantage of LAMP in building your very own applications.

author img

Nisal N

Computers has always fascinated me since I was a kid and here we are. I love travelling for 2 reasons: the first one to see a new part of the world and second (the most important one) to experience the rich culture hidden among the country and people. I'm pretty good at cooking but very poor when it comes to baking.

Leave A Comment