How To Install LAMP Stack On Ubuntu

Here we will show that how to install LAMP (Linux Apache Mysql & PHP) on the ubuntu.

We are doing this step by step.

1- Login into server by using terminal:

This step is require for those who want install the LAMP on any remote server. Login by using ssh access.

ssh user@host_ip_address

2- Upgrade & Update the system:

By running the given below command, we will upgrade & update the system.

sudo apt-get update && apt-get upgrade

3- Install Apache :

By running the given below command, we will install Apache.

sudo apt-get install apache2

After doing this, we can see the apache details by hitting given below URL on the browser.

http://localhost/ or http://server-ip-address/

4- Install PHP:

There are many stable version of PHP, we can install any version of PHP as per requirement of Application;

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0

After this, install php module as per install php version.

sudo apt-get install php-pear php7.0-dev php7.0-zip php7.0-curl php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-xml libapache2-mod-php7.0

OR

We can install latest version of PHP

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.3

Check php details on the browser

create a phpinfo.php file by using given below command.

cd /var/www/html
sudo vi phpinfo.php

Put the below code into the file:

<?php
echo phpinfo();
?>

Restart Apache Server

sudo service apache2 restart

After doing this, we can see the php details by hitting given below URL on the browser.

http://localhost/phpinfo.php or http://server-ip-address/phpinfo.php 

5- Install Mysql:

sudo apt install mysql-server
sudo mysql_secure_installation

 

6- Install phpMyAdmin:

Before installing phpmyadmin, we will update the server by running given below command:

sudo apt-get update

Now we will run the phpmyadmin install command.

sudo apt-get install  phpmyadmin

After installing phpmyadmin, we will do some configuration into apache related to phpmyadmin.

sudo vi /etc/apache2/conf-available/phpmyadmin.conf

We need to add an AllowOverride All directive within the <Directory /usr/share/phpmyadmin>section of the configuration file, like this:

<Directory /usr/share/phpmyadmin>
    Options FollowSymLinks
    DirectoryIndex index.php
    AllowOverride All

 

sudo service apache2 restart

Now we can see the phpmyadmin by using given below URL:

https://domain_name_or_IP/phpmyadmin

Leave a Reply

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