How to Install LAMP Stack on Ubuntu 20.04

Install LAMP Stack on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure a LAMP Stack on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

LAMP is a complete package to run any web application on a server. LAMP signifies the Linux, Apache, MySQL, and Php. Apache is used as the webserver for hosting an application whereas MySQL is used as systematic data storage of application and Php is a popular server-side scripting language that is used for web development as well bridging the gap between application and the database.

Install LAMP Stack on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

Step 2. Install Apache.

Apache Webserver packages are available on Ubuntu 20.04 official repositories. All that’s needed is the execution of install command with sudo:

After it’s installed, Apache should be automatically started. Check its status with systemctl.

Step 3. Install MySQL.

The next component of your LAMP Stack on Ubuntu 20.04 is MySQL. Begin by updating the repositories and installing the MySQL package:

Once the package installer has finished, we can check to see if the MySQL service is running:

After that, you should now run mysql_secure_installation to configure security for your MySQL server on Ubuntu 20.04:

Step 4. Install PHP.

Now that we have both Apache and MariaDB installed, the missing piece is PHP. We will install PHP and standard extensions which are commonly used. Enter the following command to install PHP7.4 and some common PHP modules:

Once the PHP packages are installed restart the Apache service with:

Check PHP version information:

Step 5. Testing PHP

Now you should create info.php file to test php to do so type following:

Then open the following link in your web browser and we will be able to see all the information about PHP and its other configurations: http://your-domain/phpinfo.php (replacing your IP address with the one above).

That’s all you need to do to install Apache, MySQL, PHP (LAMP) Stack on Ubuntu 20.04. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.