
How to Install LAMP Web Server?
A LAMP (Linux, Apache, PHP and MySQL) stack is a common, free, and open-source web stack used for hosting web content in a Linux environment. And this server is used for high performance web app deployment.
This guide shows how to install and test a LAMP stack on Ubuntu 18.04 (LTS).
At first we need to update our system to the latest version
sudo apt update && sudo apt upgrade
Installing LAMP Stack
1. Install Apache2
after installing apache2 use the 2nd command to get your machine IP address and paste it in your browser (ex: http//:192.168.2.22)
sudo apt install apache2ip address
2. Install PHP and Most Important Libraries
sudo apt-get install php php-curl php-xml libapache2-mod-php php-mysql php-mbstring php-gettext php-json php-cgi
3. Add PHP File
add a new php file that loads PHP version and details
cd /var/www/htmlsudo nano phpinfo.php
write down the below PHP code then press (ctrl + O then ctrl + X)
<?php phpinfo(); ?>
4. Installing MySQL
sudo apt-get install mysql-server mysql-client sudo mysql_secure_installationsudo phpenmod mbstringsudo systemctl restart apache2
5. Configure MySQL
login with root account into mysql server. Then view user (the 2nd command) you’ll find that root password is not set yet. Enter the 3rd command to set root password and exit.
- mysql -u root -p - SELECT user,authentication_string,plugin,host FROM mysql.user; - ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your password';- exit;
6. Install PHPMyAdmin
Install PHPmyAdmin, then open the apache configuration file. And write down the 3rd line then save and exit. to access PHPmyAdmin http://yourIP/phpmyadmin or http://localhost/phpmyadmin/
sudo apt-get install phpmyadminnano /etc/apache2/apache2.confInclude /etc/phpmyadmin/apache.confsave and exit (ctrl + O then ctrl + X)
Thank you for reading!
Share this article
