Install LAMP Stack on Ubuntu 20.04 Server

Install LAMP Stack on Ubuntu 20.04 Server

What is LAMP???

LAMP is an open source Web development platform that uses Linux as the operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language.

I am using DigitalOcean for creating the VPS but you can use any service provider of your choice. As long as the operating system of your server is Ubuntu, the following steps will work to install LAMP on your server.

Installing Apache

Apache is an amazing web server and is the most commonly used Web server on Linux systems.

sudo apt update

Screenshot 2022-02-11 at 8.35.40 AM.png The above command updates the package lists for upgrades. Let's run it to ensure that we install the latest versions of the packages. To install Apache, run the following command

sudo apt install apache2

Screenshot 2022-02-11 at 8.36.19 AM.png Press Y when prompted and the installation will finish after a while. To allow Apache through the firewall use the following command:

sudo ufw allow in "Apache Full"

You can now go to the server URL (IP address of your VPS) and the apache2 default page will be displayed on the screen.

Screenshot 2022-02-11 at 8.39.46 AM.png If you can see the above default page, then you have successfully installed Apache on your sever.

Installing MySQL

MySQL is a very popular and open source database that can be used with almost any application to store data effectively.

Execute the following command to install MySQL.

sudo apt install mysql-server

Screenshot 2022-02-11 at 8.40.54 AM.png Confirm the installation by pressing "y" when prompted. One the installation is done, you should be able to login into MySQL console by using "sudo mysql". To exit the mysql console, use "exit" command.

Installing PHP

sudo apt install php libapache2-mod-php php-mysql

Screenshot 2022-02-11 at 8.41.11 AM.png This will install the following 3 packages

  • php - installs PHP
  • libapache2-mod-php - Used by apache to handle PHP files
  • php-mysql - PHP module that allows PHP to connect to MySQL
    php -v
    
    Screenshot 2022-02-11 at 8.41.41 AM.png Congratulations! we have successfully installed LAMP stack on your server.

Did you find this article valuable?

Support Srinivas Karnati by becoming a sponsor. Any amount is appreciated!