> ## Content Index
> Fetch the complete content index at: https://www.blog.nestict.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Install Apache, MySQL, PHP, and phpMyAdmin on Ubuntu 24.04
- URL: https://www.blog.nestict.com/how-to-install-apache-mysql-php-and-phpmyadmin-on-ubuntu-24-04/
- Published: 2025-09-13T08:09:55.000Z
- Updated: 2025-11-12T10:58:28.000Z
- Author: Nestict Infotech CSR
- Tags: Technology, Featured

# 🚀 How to Install Apache, MySQL, PHP, and phpMyAdmin on Ubuntu 24.04

If you’re setting up a web server on Ubuntu 24.04, the classic stack of **Apache, MySQL, PHP, and phpMyAdmin** is still one of the most reliable choices. This combination (often called a LAMP stack) gives you everything you need to host dynamic websites and manage your databases through a user-friendly interface.

In this guide, I’ll walk you through the exact steps I used to install and configure it successfully.

---

## 🔹 Step 1: Update Your System

Before installing any packages, make sure your system is up to date:

```bash
sudo apt update && sudo apt upgrade -y

```

---

## 🔹 Step 2: Install Apache

Apache is the web server that will serve your websites:

```bash
sudo apt install apache2 -y

```

Enable Apache on boot:

```bash
sudo systemctl enable apache2
sudo systemctl start apache2

```

Test it by visiting your server’s IP in a browser:

```
http://your-server-ip

```

You should see the default Apache welcome page.

---

## 🔹 Step 3: Install MySQL

Next, install MySQL, the database system:

```bash
sudo apt install mysql-server -y

```

Secure MySQL and set a root password:

```bash
sudo mysql

```

Inside the MySQL shell, run:

```sql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourPasswordHere';
FLUSH PRIVILEGES;
EXIT;

```

---

## 🔹 Step 4: Install PHP

Now install PHP along with common extensions:

```bash
sudo apt install php libapache2-mod-php php-mysql php-cli php-mbstring php-zip php-gd php-json php-curl -y

```

Check version:

```bash
php -v

```

---

## 🔹 Step 5: Install phpMyAdmin

Ubuntu 24.04 doesn’t automatically configure phpMyAdmin in Apache, so we’ll handle that manually:

```bash
sudo apt install phpmyadmin -y

```

Create a new Apache config file:

```bash
sudo nano /etc/apache2/conf-available/phpmyadmin.conf

```

Add the following:

```apache
Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php
    AllowOverride All
    Require all granted
</Directory>

<Directory /usr/share/phpmyadmin/setup>
    Require local
</Directory>

```

Enable and reload Apache:

```bash
sudo a2enconf phpmyadmin
sudo systemctl reload apache2

```

---

## 🔹 Step 6: Access phpMyAdmin

Now you can log in:

```
http://your-server-ip/phpmyadmin

```

Use:

- **Username**: `root`
- **Password**: the one you set in MySQL

---

## 🎯 Final Thought

You now have a fully working **LAMP stack with phpMyAdmin** on Ubuntu 24.04.  
This setup is perfect for hosting WordPress, Drupal, Joomla, or any PHP-based application.

For better security, I recommend:

- Creating a dedicated MySQL user instead of using `root`
- Setting up a firewall with UFW
- Installing Let’s Encrypt SSL for secure HTTPS access

With this stack ready, you’re only a few clicks away from deploying your first web app! 🚀