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

Read Time: 4 mins

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 16.04 to the latest by running apt-get update

 

Screenshot

Video Demonstration:

Please LIKE , COMMENT  and SUBSCRIBE .

Subscribe EasyAsLinux channel  

Step1. Install Apache for LAMP in Ubuntu 16.04:

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 Ubuntu 16.04 box, let’s setup php.

Step2. Install PHP for LAMP in Ubuntu 16.04:

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.

Now we have installed PHP in our Ubuntu 16.04 box. Let’s go for MySQL.

Step3. Install MySQL for LAMP in Ubuntu 16.04:

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 in our Ubuntu 16.04 box. 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 (Checkout Right Sidebar for the Subscription Form).

 

A Site Reliability Engineer and an automation enthusiast.
Posts created 35

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

Back To Top
x