LAMP Stack — Install WordPress on Linux
LAMP stands for Linux, Apache, MySQL, and PHP — the classic open-source combination used to host WordPress on real servers (Ubuntu is the most common Linux distribution for this).
What is a LAMP stack?
LAMP stands for Linux, Apache, MySQL, and PHP — the classic open-source combination used to host WordPress on real servers (Ubuntu is the most common Linux distribution for this).
Real-life example: LAMP is like the four legs of a table — Linux is the floor it stands on, Apache serves the pages, MySQL stores the data, and PHP does the cooking (logic) in between.
Install Apache, MySQL, and PHP on Ubuntu
On a fresh Ubuntu server (a VPS, for example), update your package list, then install each piece of the stack one at a time.
sudo apt update && sudo apt upgrade -y
# Apache web server
sudo apt install apache2 -y
sudo systemctl enable apache2
sudo systemctl start apache2
# MySQL database
sudo apt install mysql-server -y
sudo mysql_secure_installation
# PHP + common modules WordPress needs
sudo apt install php php-mysql php-curl php-gd php-mbstring php-xml php-zip -y
sudo systemctl restart apache2Create the database and deploy WordPress
Log in to MySQL as root, create a dedicated database and user for WordPress (never use the root MySQL account inside wp-config.php), then download and extract WordPress into Apache's web root.
- Create a dedicated DB user — never point wp-config.php at the root MySQL account
- www-data ownership lets Apache read/write uploads and updates safely
- Visit your server's IP or domain to run the same 5-minute install as local setups
sudo mysql -u root -p
# Inside the MySQL prompt:
CREATE DATABASE wordpress_db;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'Str0ngP@ssword!';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
sudo cp -a wordpress/. /var/www/html/
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/