Posted on 12-08-2025 | Category: General | Views: 139
WordPress powers over 40% of the internet, and hosting it on Amazon Web Services (AWS) gives you the flexibility, security, and scalability you need. This guide will walk you through creating an AWS EC2 instance, installing Ubuntu, setting up Apache, and deploying WordPress from scratch.
Log in to AWS Management Console
Go to https://aws.amazon.com/console/ and sign in.
Launch a New EC2 Instance
Navigate to EC2 Dashboard → Launch Instance.
Enter Instance Name (e.g., wordpress-server).
Choose an Amazon Machine Image (AMI)
Select Ubuntu Server 22.04 LTS (Free tier eligible).
Choose Instance Type
Select t2.micro (Free Tier) or larger if needed.
Key Pair for SSH
Create a new key pair (e.g., wordpress-key.pem).
Download it immediately — you cannot download it again later.
Configure Network Settings
Allow HTTP (80), HTTPS (443), and SSH (22) from 0.0.0.0/0.
Launch Instance
Click Launch Instance and wait until the status is Running.
From your local machine terminal:
chmod 400 wordpress-key.pem
ssh -i "wordpress-key.pem" ubuntu@<Public-IP-of-EC2>
sudo apt update && sudo apt upgrade -y
sudo apt install apache2 -y
sudo systemctl enable apache2
sudo systemctl start apache2
Check Apache:
Visit http://<EC2-Public-IP> → You should see the Apache default page.
sudo apt install php libapache2-mod-php php-mysql php-cli php-curl php-xml php-mbstring unzip -y
sudo apt install mysql-server -y sudo mysql_secure_installation
Create a WordPress database and user:
sudo mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Download WordPress
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
Move Files to Web Directory
sudo mkdir -p /var/www/wordpress
sudo rsync -av wordpress/ /var/www/wordpress/
Set Permissions
sudo chown -R www-data:www-data /var/www/wordpress
sudo chmod -R 755 /var/www/wordpress
Create a new site config:
sudo nano /etc/apache2/sites-available/wordpress.conf
Paste:
<VirtualHost *:80> ServerAdmin admin@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/wordpress <Directory /var/www/wordpress> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined </VirtualHost>
Enable site & rewrite module:
sudo a2ensite wordpress.conf sudo a2enmod rewrite sudo systemctl restart apache2
Go to:
http://<EC2-Public-IP>/
or your domain name.
Enter database details:
Database Name: wordpress
Username: wpuser
Password: StrongPassword123!
Host: localhost
Complete the installation.
Enable UFW firewall:
sudo ufw allow 'Apache Full'
sudo ufw enable
Regularly update:
sudo apt update && sudo apt upgrade -y
Consider enabling SSL via Let’s Encrypt:
sudo apt install certbot python3-certbot-apache -y sudo certbot --apache
You now have a fully functional WordPress site hosted on AWS EC2 with Ubuntu and Apache. This setup offers full control, scalability, and the power of cloud hosting.