How to install apache mysql php phpmyadmin (lamp) stack on ubuntu 20.04
Let us install apache, PHP, MYSQL, Phpmyadmin on ubuntu operating system.
Most Important:
switch over to root user #, rightnow by using the below command, so you dont have to use the stupid sudo everytime.
- sudo su
Before proceeding to install LAMP, we must confirm that we are up-to-date on apt repository and all dependencies,
Run the below command:
- apt update
- apt upgrade && apt dist-upgrade
Once, Completed,Follow the simple steps below: copy and paste one by one
Install Apache2 Web-Server:
- apt install apache2 -y
- service apache2 status
Its time to install the MYSQL:
- apt install mysql-server -y
- mysql_secure_installation
Follow as per the screenshot below for easy fix of mysql_secure_installtion:
After mysql_secure_installation,Open Mysql in Terminal to fix password to work with the phpmyadmin.
- mysql
Inside Mysql Shell run the below commands as shown in screenshot:
- SELECT user,authentication_string,plugin,host FROM mysql.user;
- ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'welcome@123';
Type exit to close mysql shell and return back to terminal.
- exit
Install PHP:
- add-apt-repository ppa:ondrej/php
- apt update
- apt install php7.4 php7.4-xml php7.4-common php7.4-zip php7.4-dev php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.4-opcache php7.4-mbstring php7.4-gd php-pear libapache2-mod-php7.4 php7.4-cli php7.4-mongodb
Based on your PHP version requirement, you can copy-paste above command on a notepad and replace 7.4 to 7.2 or 8.0 or any of your desired php version.
Install Phpmyadmin: (Select apache2 on phpmyadmin install)
- apt install phpmyadmin
After the Phpmyadmin Installation:
Run the command below to add PHPMYADMIN on apache2 configuration file.
- echo "Include /etc/phpmyadmin/apache.conf" >> /etc/apache2/apache2.conf
- service apache2 restart
Verify Phpmyadmin by going to http://localhost/phpmyadmin
To GET PHP-INFORMATION Page:
- echo "<?php phpinfo(); ?>" >> /var/www/html/info.php
Now, Goto http://localhost/info.php:
You've Made it! Apache + MYSQL + PHP Installed.😀
Share, Like and Follow US on
Control your PC with Smartphone using Remote Desktop App or Team Viewer App
No comments: