Verified and Tested 06/12/2021
In this How-To, we install LAMP on an Ubuntu 20.04 Cloud Server. LAMP is a simple software bundle of 4 components, Linux, Apache, MySQL, and PHP. Linux is the platform’s core; in this case, we are using Ubuntu 20.04 LTS. Apache is the webserver; most of the web servers globally are running Apache MySQL, a database management system developed by Oracle. PHP is an extremely popular programming language widely used in web development. Altogether this forms LAMP or LAMP stack.
In This Article
A server with Ubuntu 20.04 installed. Get a reliable VPS from Atlantic.Net if you do not have one.
Installing LAMP on Ubuntu 20.04
Before we begin the installation, your system must be up to date; you can do so with the following command:
Once updating, we can get to the first step of making a LAMP stack by installing Apache.
Installing Apache on Ubuntu 20.04
Install Apache by running the following command:
apt-get install apache2
Hit enter when it asks, “Do you want to continue?” during the install.
After the install, you can check to see if Apache is running by running the command:
systemctl status apache2
Also, you can verify if all is working by opening your browser and going to http://youripaddress
If you do not know your IP address, you can run the following command:
ip addr show eth0
In our case, we would put http://220.127.116.11 in your browser’s address bar and get the following page:
Installing MySQL on Ubuntu 20.04
Install MySQL with the following command:
sudo apt-get install mysql-server libapache2-mod-php php-mysql
After installing MySQL server, secure the MySQL server with the following command:
Note: You will be prompted with a series of questions. Just type N for the change root password and Y for yes on all of the rest; see the screenshot below:
Verify that MySQL is running with the following command:
systemctl status mysql
Installing PHP on Ubuntu 20.04
Install PHP with the following command:
apt-get install php
Create a test PHP file called info.php in /var/www/html/. In this how-to, we will be using the text editor nano with the following command:
Insert the following code in the text editor, then save and exit:
<?php phpinfo(); ?>
Since we made changes, we need to restart Apache so that the changes take effect:
systemctl restart apache2
Test your page in your browser with the following hyperlink changed with your IP address:
Congratulations! You have just installed LAMP on your Ubuntu 20.04 Server. Thank you for following this How-To on installing LAMP; please check back for more updates.