# Installing a LAMP stack on an Ubuntu server

> Install a full LAMP stack of Apache, MySQL and PHP on an Ubuntu server so you can host web applications.

Source: https://helpcenter.ruachost.com/developers/web-development/installing-a-lamp-stack-on-an-ubuntu-server/

Learn how to quickly install a complete LAMP (Linux, Apache, MySQL, PHP) stack on an Ubuntu server.

### About LAMP

A **LAMP stack** is an open-source software bundle used for hosting web applications. It includes:

- **Linux** – the operating system (already installed on your server)
- **Apache** – the web server
- **MySQL** – the database management system
- **PHP** – the server-side programming language

Many popular web applications, like WordPress, run on a LAMP stack.

>

> **Note:**
This guide applies only to **unmanaged hosting packages**. You must have root access to install Ubuntu and a LAMP stack.

### Installing a LAMP stack on Ubuntu

The following steps assume Ubuntu is installed on your server.

1. **Log in via SSH** as the root user.
2. #### Update the system

```
apt update
apt upgrade
```

3. #### Install and run tasksel

```
apt install tasksel
tasksel
```

The `tasksel` interface lists predefined software collections for installation.

4. #### Install the LAMP server

- Use the arrow keys to highlight **LAMP server**.
- Press **Spacebar** to select it, then **Enter** to start the installation.
- When prompted, set a password for the MySQL root user.

5. #### Verify the installation

- **Test Apache:** Open your web browser and visit your server’s domain or IP address. You should see the default Apache page.
- **Test PHP:** Run the following command:

```
php --version
```

> **Tip:** To confirm PHP is integrated with Apache, create a web page containing `phpinfo()` and load it in your browser. This displays PHP configuration details.

6. **Secure MySQL:** Strengthen MySQL security by running:

```
mysql_secure_installation
```

Follow the prompts to configure additional security settings.

### More information

- [LAMP stack (Wikipedia)](https://en.wikipedia.org/wiki/LAMP_(software_bundle))
- [Ubuntu official site](https://ubuntu.com/)
