How to Install LAMP on Ubuntu: A Step-by-Step Guide for Beginners
LAMP is an acronym for Linux, Apache, MySQL, and PHP – a popular stack for creating and deploying dynamic web applications.
In this web stack, Linux serves as the web application’s operating system. Apache acts as the web server that processes and retrieves content from the MySQL database. Meanwhile, PHP enables your system to process dynamic content.
👉
Start your website with Hostinger – get fast, secure hosting here
👈
Prerequisites for Installing LAMP
Before you read this Ubuntu LAMP tutorial further, ensure that all the required tools are prepared for a smooth installation process.
- Virtual Private Server (VPS) running Ubuntu 22.04
- Secure Shell (SSH) connection for remote installation
- Terminal or software like PuTTY for running SSH commands
We recommend using Hostinger’s VPS solution for easy installation and full root access via SSH. Visit our LAMP VPS hosting page to explore the available plans.
How to Install LAMP on Ubuntu at Hostinger
At Hostinger, you can easily install LAMP using an operating system template via hPanel. This method is suitable for newcomers since it doesn’t require any command, making the process easier and safer.
Here are the steps to install LAMP on Ubuntu at Hostinger:
Log in to hPanel and click VPS on the top menu.
Select the VPS hosting plan on which you want to install LAMP.
From the sidebar, click OS & Panel → Operating system.
In the Change OS section, click Application.
Select LAMP stack from the list of options, then click Change OS to confirm.
Follow the instructions to set a new root password.
Once the installation process is finished, you should see a confirmation message. If you enter your server’s IP address into a web browser, you should see the Apache welcome page.
How to Install LAMP on Ubuntu Manually
If you prefer a particular version of each software in your stack, consider installing LAMP manually using commands. Here's how:
1. Install Apache Web Server
Start the installation by updating your system’s package manager to ensure you have the latest software versions. Use the following commands:
sudo apt update
sudo apt upgrade
Now install Apache2 with the following command:
sudo apt-get install apache2
Check whether Apache is successfully installed by opening your browser on your local machine and entering your VPS IP address. You should see the Apache default page.
2. Install MySQL
MySQL is the database for your application. Install it using the following command:
sudo apt-get install mysql-server
During installation, Terminal will prompt you for the MySQL root user password. Use a secure credential. Once installed, check the MySQL service status with the following command:
sudo systemctl status mysql
3. Install PHP
PHP interprets your application’s code. Install it and other essential modules with the following command:
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql php-cgi php-curl php-json
Create a test PHP file to check if PHP is working correctly. Use the following commands:
sudo apt-get install nano
sudo nano /var/www/html/test.php
Inside the nano text editor, enter the following code:
phpinfo();
?>
Save the changes and open the test file in your browser using your server’s IP address. You should see PHP information displayed.
After confirming that PHP works correctly, remove the test file to avoid exposing server configuration information:
sudo rm /var/www/html/test.php
Conclusion
LAMP is a popular web stack for creating and deploying applications. The easiest way to install LAMP on Ubuntu is using Hostinger’s operating system template. Alternatively, you can install LAMP manually. Ensure that all prerequisites are met and follow the step-by-step guide provided in this article.
By Prithviraj S. & Aris S.
👉
Start your website with Hostinger – get fast, secure hosting here
👈
🔗 Read more from MinimaDesk:
- The Ultimate Guide to WP-Content: Access, Upload, and Hide Your WordPress Directory
- 40 Essential WordPress SEO Tips to Boost Your Website's Rankings
- How to Add and Customize RSS Feeds in WordPress
- How to Enable and Configure reCAPTCHA on WordPress: A Complete Guide
🎁 Download free premium WordPress tools from our
Starter Tools page
.
📦 Download your Free WordPress Starter Pack
📌 Originally published at MinimaDesk