How to Install Linux, Apache, MySQL and PHP ( LAMP ) stack in Ubuntu 18.04.1 / Ubuntu 18.10 (Video)

Read Time: 4 mins

In this article, Let me explain how you can setup a LAMP server with default configuration in Ubuntu 18.04.1 /  Ubuntu 18.10. Majority of the websites in the internet are running on LAMP stack which is a combination of Linux Apache MySQL and PHP. LAMP servers are very popular and it is easy to setup.

 


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

Video Demonstration:

This video is for Ubuntu 16.04, but same commands are used for Ubuntu 18.04.1 / Ubuntu 18.10(Except PHP installation command).


Subscribe EasyAsLinux channel  

Please LIKE , COMMENT  and SUBSCRIBE .

Step1. Install Apache for LAMP in Ubuntu 18.04.1 / 18.10:

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.

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

 

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 )

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

 

So you got the apache running fine our Ubuntu 18.04.1 / Ubuntu 18.10, let’s setup php.

Step2. Install PHP for LAMP in Ubuntu 18.04.1 / 18.10:

Let’s install PHP7.2  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

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.

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 PHP installed in our Ubuntu 18.04.1 / Ubuntu 18.10. Let’s install MySQL.

Step3. Install MySQL for LAMP in Ubuntu 18.04.1 / 18.10:

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

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.

 

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 your Ubuntu 18.04.1 / Ubuntu 18.10.. 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 >>

Let me come back with other useful articles soon. Subscribe  to this blog so that you don’t miss out anything useful (Checkout Right Sidebar for the Subscription Form) . Please also put your thought on this article as a  comment .

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

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

Back To Top
x