How To Install LAMP (Linux, Apache, MySQL, PHP) On Ubuntu
A LAMP (Linux, Apache, MySQL and PHP) stack is a group of open source software that is typically installed together to enable a server to host dynamic web application and are the fundamentals of a LAMP web server. Because the platform has four layers, LAMP is sometimes referred to as a LAMP stack. Stacks can be built on different operating systems. The LAMP bundle can be combined with many other free and open-source software packages. The site data is stored in a MySQL database, and dynamic content is processed by PHP.
Before You Begin:
(1) To do Open Terminal use this shortcut key
Ctrl + Alt + t
(2)Update your system:
sudo apt-get update
Step 1: Install Apache
Apache2 is available within Ubuntu 16.04 is default software repositories, so we will install it using conventional package management tools. Alternatively, you can open a terminal and type the following command
sudo apt-get install apache2
We are using a sudo command, these operations get executed with root privileges.
using below command you can do check that installed Apache or not.
You will see the default Ubuntu 16.04 Apache web page.
If the page is open according to the above image, then your web server is now correctly installed and accessible through your firewall.
Step 2: Install CURL
in this method use to the curl utility to contact. Run the following set of commands to install curl on Ubuntu 16.04 in Terminal.
sudo apt-get install curl
Once installed CURL, we can check curl version using the command given below.
Step 3: Install MySQL
you can installed MySQL by using the apt package manager, MySQL is an open source database management system. First make sure your packages list are up to date. you can open a terminal and run the following apt command.
sudo apt-get install mysql-server
Enter time 'y' when prompted with whether or not you want to install the new package.
Once installed MySQL, we can check MySQL using the URL given below.
Step 4: Install PHP
Install PHP using the command given below.
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
This should install PHP without any error. We'll test this in a moment.
you will be changing open file first priority index.html to index.php
To do this, using the command given below to open the dir.conf file in a text editor with root privileges:
sudo nano /etc/apache2/mods-enabled/dir.conf
It will look like this:
<IfModule mod_dir.c> DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm </IfModule>
<IfModule mod_dir.c> DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm </IfModule>
After this, we need to restart the Apache
sudo systemctl restart apache2
Step 5: Install PHP Modules
To enhance the functionality of PHP, we can optionally install many additional modules.
you can look at the long description of the package by typing:- apt-cache show package_name
all supported PHP development packages
sudo apt-get install php-all-dev
CURL module for PHP (default)
sudo apt-get install php-curl
server side, HTML embedded scripting language (CGI binary) (default)
sudo apt-get install php-cgi
command-line interpreter for the PHP scripting language (default)
sudo apt-get install php-cli
Common files for PHP packages
sudo apt-get install php-common
GD module for PHP (default)
sudo apt-get install php-gd
Files for PHP module development (default)s
sudo apt-get install php-dev
GMP module for PHP (default)
sudo apt-get install php-gmp
Step 6: Test PHP and get details about your PHP installation
Go to this directory /var/www/html and Create info.php file thene add code below
<?php phpinfo(); ?>
below URL, run info.php file in a browser