Showing posts with label #WebDevelopment. Show all posts
Showing posts with label #WebDevelopment. Show all posts

Tuesday, September 15, 2026

Learn how to install Apache, MySQL and PHP on Ubuntu. Complete LAMP stack installation guide with one-shot commands, PHP testing and php-opcache troubleshooting

How to Install LAMP Stack on Ubuntu | Complete Guide
UBUNTU • LINUX • SERVER • PHP

How to Install LAMP Stack on Ubuntu

A complete step-by-step guide to installing Apache, MySQL and PHP on Ubuntu — including a one-shot installation command and a fix for the common php-opcache package error.

The LAMP stack is one of the most popular environments for hosting PHP applications on Linux. It combines Linux, Apache, MySQL and PHP into a complete web application platform.

Whether you're building a WordPress website, Laravel application, PHP API or simply creating a local development environment, installing LAMP gives you everything you need to get started.

What Does LAMP Stand For?

🐧

Linux

The operating system powering the server.

🌐

Apache

Handles HTTP requests and serves web pages.

🗄️

MySQL

Stores and manages application data.

🐘

PHP

Processes dynamic server-side application code.

How the LAMP Stack Works

A typical request flows through the stack like this:

Browser HTTP Request
Apache Web Server
PHP Application
MySQL Database

Install LAMP on Ubuntu

First update your Ubuntu package index:

Terminal
sudo apt update

Install Apache, MySQL and PHP

You can install the complete LAMP environment with the following command:

One-shot installation
sudo apt install -y apache2 mysql-server php libapache2-mod-php php-mysql php-cli php-curl php-gd php-mbstring php-xml php-zip php-bcmath php-intl php-soap

Start Apache and MySQL

Enable both services so they start automatically with Ubuntu:

Terminal
sudo systemctl enable --now apache2 mysql

Enable Apache URL Rewriting

The Apache rewrite module is commonly required by modern PHP applications and frameworks such as Laravel.

Terminal
sudo a2enmod rewrite
sudo systemctl restart apache2

Featured Posts

Learn how to install Apache, MySQL and PHP on Ubuntu. Complete LAMP stack installation guide with one-shot commands, PHP testing and php-opcache troubleshooting

How to Install LAMP Stack on Ubuntu | Complete Guide UBUNTU • LINUX • SERVER • PHP ...