Install Apache2 PHP MYSQL PHPMyAdmin ubuntu 20.04|18.04

There are some commands to install Apache 2, PHP, MySQL and PHPMyAdmin in Ubuntu 20.4, which you can do it very easily. In this tutorial, we will tell you how to install Lamp (Apache2 PHP MYSQL PHPMyadmin) on Ubuntu 18.04/20.04 server.

Before we install Lamp in Ubuntu. Let’s know about lamp:

  • L => Linux operating system
  • A => Apache web server
  • M => MySQL relational database management system
  • P => PHP object-oriented scripting language

Here are steps to install Apache 2 mysql php phpmyadmin ubuntu 18.04|20.04:

  • 1. Install Apache 2 On Ubuntu
  • 2. Install MySQL on Ubuntu
  • 3. Install PHP 7.2 On Ubuntu
  • 4. Test PHP Version
  • 5. Install PhpMyAdmin

Before Installing the Lamp on Ubuntu. First update the apt package :

sudo apt-get update

sudo apt-get upgrade 

1. Install Apache 2 On Ubuntu

Install Apache on ubuntu using the below command:

sudo apt-get install apache2

Check Apache Status:

After the Apache installation process, the web server service should be started automatically, You can check the Apache service status :

sudo systemctl status apache2
                                    Output

apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           `-apache2-systemd.conf
   Active: active (running) since Sun 2018-12-31 05:18:45 PDT; 2min 30s ago
 Main PID: 3143 (apache2)
    Tasks: 55 (limit: 2321)
   CGroup: /system.slice/apache2.service
           |-3143 /usr/sbin/apache2 -k start
           |-3144 /usr/sbin/apache2 -k start
           `-3145 /usr/sbin/apache2 -k start

Manage the Apache services using these below commands :

To start Apache

sudo systemctl start apache2

To Stop Apache

 sudo systemctl stop apache2 

Restart Apache

sudo systemctl restart apache2

Disable Apache

sudo systemctl disable apache2

2. Install MySQL on Ubuntu

Execute the following command to install MySQL server into your ubuntu server:

sudo apt install mysql-server

Secure MySQL Server Installation

Default MySQL is insecure , we need to secure the database server.

After installation is complete, the mysql_secure_installation utility runs. 
Run the below command and answer the few questions based on your environment requirements.

sudo mysql_secure_installation

3. Install PHP 7.2 On Ubuntu

Execute the following command to install PHP 7.2 version on ubuntu server:

sudo apt-get install python-software-properties -y 

sudo add-apt-repository ppa:ondrej/php

Install PHP with Exetension

sudo apt-get install php7.2

sudo apt-get install php7.2-<extension-name>

See example below

sudo apt-get install php7.2-fpm  php7.2-curl php7.2-mysql \  php7.2-xml php7.2-zip php7.2-gd

4. Test PHP Version

Test your server by executing the following command:

Use the below command to check the PHP version installed on your server :

php -v

Finally, we need to restart the Apache Web Server :

sudo systemctl restart apache2

5. Install PhpMyAdmin

Use the following command to Install PHPMyAdmin:

sudo apt install phpmyadmin

Configuration phpmyadmin for Apache.

sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf

Enable the configuration.

sudo a2enconf phpmyadmin.conf

Then execute the following command on command prompt to restart apache web server:

sudo service apache2 restart

Now we have installed PHPMyadmin, this can be accessible with this route yourdomain.com/phpmyadmin.

Conclusion

In this article, we have successfully installed LAMP on Ubuntu 18.04/20.04.

If you have any questions or thoughts to share, use the comment form below to reach us.

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *