Install LAMP on Ubuntu 18.04 LTS

A LAMP (Linux, Apache, MySQL, PHP) stack is free, and open-source web stack. It is used for hosting web content in a Linux environment.Many consider this as the platform of choice for high performance web apps.

In this article i will illustrate the LAMP setup process.

Ubuntu 18.04 LTS

Update and upgrade Ubuntu to the latest release using the below command.

sudo apt update && sudo apt upgrade

Install Apache

Install apache 2.4 from ubuntu repository.

sudo apt install apache2

Install Percona Server

Install latest version of Percona Server 5.7 using Percona repository.

sudo wget https://repo.percona.com/apt/percona-release_0.1-6.$(lsb_release -sc)_all.deb
sudo dpkg -i percona-release_0.1-6.$(lsb_release -sc)_all.deb
sudo apt update
sudo apt-get install percona-server-server-5.7

Install Mongo

Install latest version of MongoDB 4.0 using MongoDB repository.

sudo sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
sudo touch /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt update
sudo apt-get install -y mongodb-org

Install PHP

Install PHP 7.2 and it’s libraries and restart Apache server. You should be able to see Apache default page.

sudo apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-intl php7.2-mysql php7.2-cli php7.2-zip php7.2-curl php7.2-mongodb php-pear php7.2-dev
sudo pecl install mongodb
sudo echo "extension=mongodb.so" >> /etc/php/7.2/apache2/php.ini

Troubleshoot & Test

Now, we have setup the lamp stack, it’s time to test it.

Let’s check the php info. Create the below file and you should be able to see the php info on browser.

# cat /var/www/html/phpinfo.php 
<?php phpinfo( ); ?>
#

phpinfo

Conclusion

It’s so easy to setup lamp stack. You have done it.

@@ Enjoy…

2 Comments

  1. Do I need to install Mongo? I want to use Percona with MySQL.

  2. Hello Mohit,

    It’s up to you.
    If you need MongoDB, install it. Otherwise leave it.

Leave a Reply

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