4 steps to install Linux, Apache, MySQL and PHP ( LAMP ) server in Ubuntu 16.04

Most of the websites in the internet are running on LAMP server which is a combination of Linux Apache MySQL and PHP. LAMP servers are very popular and it is easy setup. Let me explain here how to setup a LAMP server with default configuration in Ubuntu 16.04.

Before we begin, let’s update package lists of Ubuntu to the latest by running apt-get update

 

Screenshot

 

Step1. Install Apache for LAMP:

Here is a little background of Apache. Apache is an open-source HTTP server for modern operating systems which is written C. The Apache HTTP Server (“httpd”) was launched in 1995 and it has been the most popular web server on the Internet since April 1996. Apache 2.4 is the latest stable version of Apache. If anybody still using Apache 2.2, it is time to upgrade it as Apache has discontinued all development and patch review of the 2.2.x series of releases.

Learn more about Apache from their office website https://httpd.apache.org/.
Let’s install Apache 2.4:

 

Give Y to the prompt for confirmation and wait for 2mins.

Apache Installation

 

When It is done, make sure Apache is ‘running’ by executing command.

 

Screenshot

 

If Apache is in running state, you would see the Apache default page in the browser when searched with server IP address (http://your-server-ipaddress)

Apache default page

 

Let’s enable Apache in the boot so that apache start automatically when the system is rebooted

 

So you got the apache running fine your box, let’s setup php.

Step2. Install PHP for LAMP:

Let’s install PHP7 along with few PHP modules and a module which is required to integrate PHP with Apache.

 

Give Y to the prompt for confirmation and wait for 2 mins

PHP installation

 

When it is done, go to /var/www/html (This is the default document root where you store all your website content in order to serve via your website) and create a file “info.php” with content given below.

 

Now go to http://your_server_ip_address/info.php on the browser and you will see the PHP info page as shown below.

PHP info page

 

This means that your website is now serving PHP code. If you are a PHP developer, you can put your code here and check it in the browser.

 

Let’s tell Apache to look for index.php first by making following changes. open /etc/apache2/mods-enabled/dir.conf. Current content should be looking this.

 

Change it to as below

 

And then reload Apache.

 

Step3. Install MySQL for LAMP:

A database is required when you are building a robust and data driven website. Let’s install MySQL which can be used as a database for your website.

 

MySQL installation

Give Y when prompted and also give root password for the database server when asked during installation.

 

When it is completed, check the status of the MySQL by running following command.

 

Screenshot

You should see something like this:

 

Let’s enable MySQL in the boot so that MySQL start automatically when the system is rebooted

 

That’s it you have LAMP server up and running. Now you can start developing your PHP website or you setup web applications like WordPress, Joomla, Magento.

WordPress installation on a LAMP server is explained here >>

 

I will be filling this article with a lot useful information soon. Stay tuned by subscribing to the website.

Subscribe here

An automation enthusiast who presently working as Site Reliability Engineer with 4+ year experience in the field.
Posts created 7

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top