How to Install LAMP Stack on Ubuntu

How to Install LAMP Stack on Ubuntu

LAMP stack (Linux, Apache, MySQL, PHP) is a popular combination for hosting dynamic websites or web applications on Ubuntu. Below are detailed steps to install and configure the LAMP stack on your Ubuntu server.

Step 1: Update Package Lists

    sudo apt update

Step 2: Install Apache

    sudo apt install apache2

Step 3: Adjust Firewall

    sudo ufw allow 'Apache'

Step 4: Install MySQL

    sudo apt install mysql-server

Step 5: Secure MySQL Installation

    sudo mysql_secure_installation

Step 6: Install PHP

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

Step 7: Adjust Apache Settings

    sudo nano /etc/apache2/mods-enabled/dir.conf

Step 8: Restart Apache

    sudo systemctl restart apache2

Step 9: Verify PHP Installation

Create a test PHP file to verify PHP processing:

    sudo nano /var/www/html/info.php

Add the following PHP code to the file:


Save and close the file. Open a web browser and navigate to http://your_server_IP/info.php. You should see a PHP info page displaying detailed information about your PHP installation.

Congratulations! You’ve successfully installed the LAMP stack on your Ubuntu server.


Leave a Reply

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