Deploying WordPress with MySQL on Amazon EC2 Ubuntu

3 min readOct 25, 2023


This tutorial is designed for those who are familiar with WordPress and MySQL and are looking to leverage the power of Amazon Web Services (AWS) to deploy a robust, secure, and scalable WordPress site in a production environment.

Step 1: Launch an Amazon EC2 Instance

  1. Sign in to the AWS Management Console and open the Amazon EC2 console at
  2. Click Launch Instance.
  3. In the Choose an Amazon Machine Image (AMI) page, choose the Ubuntu Server 20.04 LTS.
  4. In the Choose an Instance Type page, select the hardware of the host. For a basic WordPress site, a t2.micro type offers enough power.
  5. Click Next: Configure Instance Details, Next: Add Storage, and Next: Add Tags in order.
  6. In the Configure Security Group page, set up a security group for your instance.
  7. Review your settings and click Launch.

Step 2: Connect to Your Instance

  1. From the EC2 Dashboard, click on Instances in the left sidebar.
  2. Select your instance and click Connect.
  3. Follow the instructions provided to connect to your instance using SSH.

Step 3: Install LAMP Stack

After connecting to your instance, it’s time to install the LAMP Stack, which includes Apache, MySQL, and PHP.

sudo apt update
sudo apt upgrade
sudo apt install apache2 mysql-server php php-mysql php-xml libapache2-mod-php php-cli

Step 4: Install WordPress

  1. Download WordPress:
wget -c
tar -xzvf latest.tar.gz
  1. Set up a database for WordPress:
sudo mysql -u root -p
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'admin'@'localhost';
  1. Move WordPress files to the Apache directory:
sudo rsync -av wordpress/*…




I'm a Full-Stack Developer | AWS Certified DevOps Engineer, with passionate about coding and enjoy sharing my knowledge with others.