Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks
Install php, apache, mysql(Lamp) and phpmysadmin on Ubuntu

How to Install php apache mysql(Lamp) and phpmysadmin on Ubuntu

Aman Jain, September 18, 2021November 8, 2023

In this article we will learn to Install php apache mysql(Lamp) and phpmysadmin on Ubuntu. PHP, Apache MySQL and phpMyAdmin is most useful part to run a web application like PHP. In this tutorial we will cover installation of PHP 7, Apache, MySQL and phpMyAdmin.

Here is the list of tools and their use.

  1. PHP : To run the PHP code.
  2. Apache  : To run PHP code on a server 
  3. MySQL : To connect PHP or any language with database and store the data.
  4. phpMyAdmin: Mysql GUI to access MySQL database.

So, let’s begin with Install Apache,php,mysql Tutorial in Ubuntu

1 . How to install Apache in Ubuntu

Step 1.1 : Login into the server with ssh

First, open the terminal or putty and type below command to login into server.

ssh username@ip_or_domain

output will be :

Screenshot 2021 09 17 at 1.29.34 PM

Then it will ask for the password. After entering the password you will enter into server ssh.

Step 1.2 : Update Ubuntu System Repositories

Before install the apche we will update the Ubuntu system repositories using below command.

sudo apt update

Step 1.3: Install Apache 

sudo apt install apache2

Step 1.4 Enable/Disable firewall for Apache

sudo ufw allow 'Apache Full'

Step 1.5 Check Apache server is installed and running

sudo systemctl status apache2

//or

sudo service apache2 status

Output :

Screenshot 2021 09 17 at 1.30.29 PM

Step 1.6 Open browser and type your ip or domain 

apache2

2 . How to install MySQL in Ubuntu?

2.1 – Installing MySQL server

sudo apt-get install mysql-server

 This will install the MySQL server and won’t ask you to set the password so let’s move to the next step of securing the MySQL server.

2.2. Securing MySQL server

After the fresh installation of MySQL, we are going to secure our MySQL by strengthening the password, type of authentication and root password.

sudo mysql_secure_installation

The above command will ask many questions as below

2.2.1 Do you want to Validate password plugin

Securing the MySQL server deployment

Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No:

Press Any key for no for now.

2.2.2 Set root password for MySQL

Next prompt will be set root password .

Please set the password for root here.

New password:
Re-enter new password:

Enter the password twice and move to next step.

2.2.3 Remove Anonymous Users

Next question would be for removing Anonymous user.

Remove anonymous users? (Press y|Y for Yes, any other key for No) 

Enter Y and go ahead.

2.2.3 Disable Remote Root Login

By default, MySQL comes with a database named ‘test’ that

anyone can access. This is also intended only for testing,

and should be removed before moving into a production

environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) :

Enter Y and go ahead.

2.2.4 Reload Privilege Tables

Reloading privileges to ensure that all changes will take effect.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) :

Enter Y and go ahead.

2.2.5 Check MySQL Service

sudo service mysql status
Screenshot 2021 09 17 at 2.15.59 PM

2.2.6 Login into MySQL terminal

sudo mysql -u root -p 

Enter password and you will be in to mysql terminal.

3. Install PHP 7.3 in Ubuntu

Now, we have installed Apache and MySQL, now we are going to install PHP so we can run our PHP code and render it on browser.

Type below command to install the PHP 7.3 and 

3.1 Install php

open terminal or putty and ssh into the server, then type below command

sudo apt-get install php libapache2-mod-php php-mysql php-curl php-gd php-json php-zip php-mbstring

Above command will install php along with some extension of php.


3.2 Check PHP versions in CLI

php -v

It will show the output as below :

PHP 7.3.1 (cli) (built: Jul  5 2021 15:13:35) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.3.1, Copyright (c), by Zend Technologies

3.2 Check in browser

Go to folder /var/www/html and create a file info.php

cd /var/www/html

Then type command to edit the or create a new file

sudo vi info.php

And type

<?php 
echo phpinfo();

Then, open http://ip_domain/info.php

4. Install, Configure and Access phpMyAdmin

PhpMyAdmin is used for the mysql GUI to access the all databases, tables, structure of table and almost all task related to MySql.

Let’s install it step by step

4.1 Install phpMyAdmin

sudo apt install phpmyadmin

Above command will prompt a box like below

phpmyadmin setup
phpmyadmin setup

Select the apache2 .

4.2 Configure phpMyAdmin in Ubuntu

Configure phpmyadmin in Apache config so it will be accessible through the web panel.

sudo vi /etc/apache2/apache2.conf

And that, add the following line into apache2.conf file and save it:

Include /etc/phpmyadmin/apache.conf

Enable MySQL root Login for phpMyAdmin Ubuntu

sudo mysql -u root -p

Enter your password and then type in MySQL Session

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;

Related

Devops Ubuntu

Post navigation

Previous post
Next post

Related Posts

Softwares ssh disable

Disable SSH or IP bounded on any ubuntu server?

July 11, 2021February 22, 2024

Open SSH to everyone is a security risk. we can change these settings easily in 2 minutes. let’s have quick solution on this. Open file /etc/hosts.deny with using vi or nano editor. Command : sudo vi /etc/hosts.deny then add below line to the file. sshd,sshdfwd-X11 : ALL it will look…

Read More
Ubuntu How to Reset Root Password of MySQL 8 in Ubuntu 20.04

How to Reset Root Password of MySQL 8 in Ubuntu 20.04 ?

June 1, 2022June 1, 2022

Sometimes we forget or mistakenly type wrong password during the installation of mysql, So in this article i will help you to Reset Root Password of MySQL in Ubuntu 20.04. Mysql 8 has several new features and also it has change the default password algorithm for saving the password. Mysql…

Read More
Softwares disable change detection anagular

How to disable automatic change detection strategy in angular component?

July 4, 2021November 8, 2023

In angular all components by default take the changes as any event occur, but sometime we disable automatic change detection strategy in angular. Thus, to detach the two way binding in component we can use changeDetection strategy in component metadata. Angular Change Detection Strategy is simple to implement using the…

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • Mapping Together: The Vibrant Spirit of OpenStreetMap Japan
  • Understanding High Vulnerabilities: A Deep Dive into the Weekly Summary
  • Building a Million-Dollar Brand: The Journey of Justin Jackson
  • Mastering Schedule Management with Laravel Zap
  • The Resilience of Nature: How Forests Recover After Fires
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version