Announcement

Collapse
No announcement yet.

How to Install LAMP on Ubuntu 24.04

Collapse
X
Collapse
  •  

  • How to Install LAMP on Ubuntu 24.04


    LAMP stands for Linux, Apache, MySQL, and PHP. The open-source stack comes bundled together when you want to host dynamic web apps or websites developed in PHP. LAMP is a go-to solution for developers writing their programs in PHP, as it contains everything required to host the web app or website.

    Linux is the operating system you are using while the Apache is an open-source web server to handle HTTP requests. The MySQL is the database to handle the data, while PHP is the programming language used for the development. Installing the LAMP stack involves a few steps, and this post has covered them in detail.

    Installing a LAMP Stack on Ubuntu 24.04

    We must install each element separately and make any configurations to obtain a LAMP stack. For better understanding, we’ve presented this installation guide in phases. Let’s go through each and the steps you should take to have LAMP installed on Ubuntu 24.04.

    1. Installing Apache

    Apache is a web server, and its massive community support makes it a preferred option for many users. Even with LAMP, we must first install Apache on our Ubuntu 24.04.

    The first step is to refresh our package manager cache by updating it.

    $ sudo apt update




    We can then install the Apache package using the APT command below.

    $ sudo apt install apache2 -y




    $ sudo systemctl status apache2




    With Apache installed, we must configure our firewall to allow Apache connection. Apache supports HTTP traffic, and to make our firewall aware of this, we need a rule that allows traffic to Apache. Once you’ve added the rule, confirm the firewall status to ensure that it is active and that your firewall rule has been added. Use the following commands to achieve this.

    $ sudo ufw allow in “Apache”

    $ sudo ufw status




    Lastly, we must verify that Apache has been installed and works correctly. Apache comes with a test page. To access this test page, open your browser and visit your server’s IP address. If using localhost, your IP address would be http://localhost. If Apache is correctly installed, you will get a window showing its welcome default page.



    2. Installing MySQL

    You can install MySQL or MariaDB for the database. The database will store and manage your site’s data using SQL syntax. If you already have either MySQL or MariaDB installed, skip this step. Otherwise, install MySQL using the following command.

    $ sudo apt install mysql-server




    Next, check the MySQL status to ensure your database is active and running.

    $ sudo systemctl status mysql




    We then need to run the default MySQL script to secure the database.

    $ sudo mysql_secure_installation




    Upon running the script, you will get prompted to confirm different things. For instance, you will be prompted to disable anonymous login. Check each prompt and give the ideal response for your case.



    Once the script terminates, you’ve secured your database and can proceed with the other steps. Access the MySQL shell with the below command to verify that the DBMS works correctly.

    $ sudo mysql




    Once you’ve ascertained that it works correctly, exit the shell.

    3. Installing PHP

    Last on our LAMP stack is PHP. It is the development languages and tools that you will utilize to write your website or web app. When installing PHP, there are different packages that you can install alongside the PHP package, and it all depends on your project requirements.

    The basic packages you must install to use PHP can be installed by executing the below command.

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




    Check the installed PHP version.

    $ php -v




    Like Apache, PHP also offers a way to test it to confirm that the installation was successful. First, create the info.php file using a text editor.

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




    Inside the file, add the code in the image below. This code confirms whether the PHP installation was successful.



    Once you’ve saved the PHP file, go back to your browser and open the PHP file following the following syntax: http://server_ip/info.php. If PHP is installed successfully, its default page, like the one below, will open in the window.



    That’s it! You now have LAMP installed on Ubuntu 24.04. Feel free to use it to host your website or other activities.

    Conclusion

    LAMP is one way of installing all prerequisites for hosting websites or web apps written in PHP. You can install the LAMP stack by installing each element separately until you’ve built the complete stack on your Linux system. We’ve demonstrated how to go about it using the provided examples and by following each step, you will manage to install LAMP on Ubuntu 24.04 easily.





    More...
      Posting comments is disabled.

    Categories

    Collapse

    Article Tags

    Collapse

    There are no tags yet.

    Latest Articles

    Collapse

    • How to Disable UEFI Secure Boot on a Proxmox VE Virtual Machine
      by Kasimba
      For GPU passthrough to work or for installing specific device drivers on a Proxmox VE virtual machine, you may need to disable UEFI Secure Boot on your Proxmox VE virtual machine.

      In this article, I will show you how to disable UEFI secure boot on a Proxmox VE virtual machine.

      The procedures shown in this article will also work on any KVM/QEMU/libvirt virtual machines and virtual machines running on other virtualization platforms based on the KVM/QEMU/libvirt hyperviso...
      Today, 07:36 AM
    • Simplify Your Life with Taskwarrior's Intuitive Linux Job Scheduling
      by Kasimba



      by George Whittaker


      Introduction

      In the digital age, the ability to effectively manage time and tasks is invaluable, especially for those who work in technology and software development. Linux users, known for their preference for powerful, flexible tools, have various options for task management and scheduling. One of the standout tools in this area is Taskwarrior, a command-line task management utility that...
      Today, 07:36 AM
    • How to Set and Use Environment Variables In Bash Script
      by Kasimba
      In bash scripting, environment variables are used to save and manage the data to modify the processes in the system. Using the bash scripts, you can use the environment variables to configure the system process. Environment variables also offer security and transmit the information from one script to another.
      Hence, there are multiple uses of environment variables that you can use to enhance the automation in the Linux system. So, if you want to learn the simple ways to set and use environment...
      Yesterday, 08:50 PM
    • How to Check Bash Version
      by Kasimba
      Checking the bash version helps Linux users in many cases, including troubleshooting and finding the currently available version in the system. If you are a regular bash user, it is good to check the bash version and keep it up to date as per the latest updates available. However, if you are a newbie in bash scripting, then you probably have never encountered a situation where you need to check the bash version.
      So, in this guide, we will explain the simplest way to check the bash version...
      Yesterday, 08:50 PM
    • What is Shebang: Bash Script Header on First Line?
      by Kasimba
      As Linux enthusiasts, we all come across bash scripting as an essential part of the Linux system. However, many Linux users don’t know why the first line of the bash script contains #!. So this combination of # and ! is called shebang or shebang.
      Although shebang looks like a bash script header, it initially instructs the system about interpreters to execute the script. This concept feels a bit complicated, but that’s not true, as this guide is all about the shebang: bash script header....
      05-02-2024, 07:59 PM
    • Bash Script Loops Examples
      by Kasimba
      A loop in programming is a control structure that allows a specific code to be executed repeatedly until a condition is met. This process is repeated until no further action is required. Loop allows you to repeat the desired set of instructions numerous times to attain the desired outcome. These recursions can be useful for all tasks that require repetitive operations or when working with data collections.
      In this article, we will explore the meaning, types, and examples of loops, further...
      05-02-2024, 07:59 PM
    Working...
    X