How to install LAMP (linux, apache, mariadb, php) on ubuntu 18.04 LTS
Install LAMP stack on Ubuntu 18.04 LTS
LAMP
LAMP is an archetypal model of web service stacks, named as an acronym of the names of its original four open-source components: the Linux operating system, the Apache HTTP Server, the MySQL relational database management system (RDBMS), and the PHP programming language.
The LAMP components are largely interchangeable and not limited to the
original selection. As a solution stack, LAMP is suitable for building dynamic web sites and web applications.
In this tutorial We'll install lamp stack on ubuntu 18.04.
In this tutorial We'll install lamp stack on ubuntu 18.04.
Note:- This method can be used to install lamp stack on every linux systems.
Prerequisites
To install lamp on your system you need to have installed ubuntu 18.04 or any other linux systemStep 1: Install apache2 server
The Apache HTTP Server is a free and open-source cross-platform web server, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation. For more info on apache visit wiki.
To install apache2 server run following commands:
sudo apt update && sudo apt upgrade sudo apt install apache2
Since sudo is used you'll asked root password enter the password.
Apt package manager will let you know the amount of data to download and how much extra space will be used. Enter y and press enter.
now start and enable apache2 service.
sudo systemctl start apache2 sudo systemctl enable apache2
To start and stop apache2 service
sudo systemctl stop apache2.service sudo systemctl start apache2.service sudo systemctl enable apache2.service
Open your browser and enter "http://127.0.0.1" or "http://localhost/" in your address bar and you be greeted with a page something like this.
apache2 it works page |
If you can see this then you have successfully install and started apache2 service
Step 2: Installing mariaDb
MariaDB is a community-developed fork of the MySQL relational database management system intended to remain free under the GNU GPL. Development is led by some of the original developers of MySQL, who forked it due to concerns over its acquisition by Oracle Corporation. Contributors are required to share their copyright with the MariaDB Foundation. For more info on mariadb visit wiki.
To install mariaDb run following command
sudo apt install mariadb-server mariadb-client
To start and stop mariadb run following commands
sudo systemctl stop mariadb.service sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
To start and enable mariadb |
On older version of ubuntu: To start and stop mariadb run following commands
sudo systemctl stop mysql.service sudo systemctl start mysql.service sudo systemctl enable mysql.service
Once installation is complete run the following to configure mariadb.
sudo mysql_secure_installtion
If asked for password just click Enter and for new password press y and enter desired password.
Press enter |
press enter |
press enter |
press enter |
installation successfull |
To log into mariadb use the following command:
sudo mysql -u root -p
MariaDb comsole |
Step 3: Installing php
PHP: Hypertext Preprocessor (or simply PHP) is a server-side scripting language designed for Web development, but also used as a general-purpose programming language. It was originally created by Rasmus Lerdorf in 1994, the PHP reference implementation is now produced by The PHP Group. PHP originally stood for Personal Home Page, but it now stands for the recursive acronym PHP: Hypertext Preprocessor. For more info on php visit wiki.To install php 7.2 on ubuntu run following commands.
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
Step 4: Restart apache2 server and test php
To test php create a file "test.php" in "var/www/html/"
sudo gedit /var/www/html/test.php
Add following lines and save file
<?php phpinfo(); ?>
Now go to browser and type "http://localhost/test.php and you will page similar to this.
test.php |
Comments
Post a Comment