Ultimate Step-by-Step Guide to Launching an AWS EC2 Ubuntu Server and Installing WordPress with Apache – BisonKB

Ultimate Step-by-Step Guide to Launching an AWS EC2 Ubuntu Server and Installing WordPress with Apache

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.


Step 1: Create an AWS EC2 Instance with Ubuntu

  1. Log in to AWS Management Console
    Go to https://aws.amazon.com/console/ and sign in.

  2. Launch a New EC2 Instance

    • Navigate to EC2 DashboardLaunch Instance.

    • Enter Instance Name (e.g., wordpress-server).

  3. Choose an Amazon Machine Image (AMI)

    • Select Ubuntu Server 22.04 LTS (Free tier eligible).

  4. Choose Instance Type

    • Select t2.micro (Free Tier) or larger if needed.

  5. Key Pair for SSH

    • Create a new key pair (e.g., wordpress-key.pem).

    • Download it immediately — you cannot download it again later.

  6. Configure Network Settings

    • Allow HTTP (80), HTTPS (443), and SSH (22) from 0.0.0.0/0.

  7. Launch Instance

    • Click Launch Instance and wait until the status is Running.


Step 2: Connect to the Server

From your local machine terminal:

bash
chmod 400 wordpress-key.pem ssh -i "wordpress-key.pem" ubuntu@<Public-IP-of-EC2>


Step 3: Update Ubuntu Packages

bash
sudo apt update && sudo apt upgrade -y


Step 4: Install Apache Web Server

bash
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.


Step 5: Install PHP and Required Extensions

bash
sudo apt install php libapache2-mod-php php-mysql php-cli php-curl php-xml php-mbstring unzip -y


Step 6: Install and Configure MySQL

bash
sudo apt install mysql-server -y sudo mysql_secure_installation

Create a WordPress database and user:

bash
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;


Step 7: Download and Configure WordPress

  1. Download WordPress

bash
cd /tmp wget https://wordpress.org/latest.tar.gz tar -xvzf latest.tar.gz

  1. Move Files to Web Directory

bash
sudo mkdir -p /var/www/wordpress sudo rsync -av wordpress/ /var/www/wordpress/

  1. Set Permissions

bash
sudo chown -R www-data:www-data /var/www/wordpress sudo chmod -R 755 /var/www/wordpress


Step 8: Configure Apache Virtual Host

Create a new site config:

bash
sudo nano /etc/apache2/sites-available/wordpress.conf

Paste:

apache
<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:

bash
sudo a2ensite wordpress.conf sudo a2enmod rewrite sudo systemctl restart apache2


Step 9: Configure WordPress

  1. Go to:

cpp
http://<EC2-Public-IP>/

or your domain name.

  1. Enter database details:

    • Database Name: wordpress

    • Username: wpuser

    • Password: StrongPassword123!

    • Host: localhost

  2. Complete the installation.


Step 10: Secure Your Setup

  • Enable UFW firewall:

bash
sudo ufw allow 'Apache Full' sudo ufw enable

  • Regularly update:

bash
sudo apt update && sudo apt upgrade -y

  • Consider enabling SSL via Let’s Encrypt:

bash
sudo apt install certbot python3-certbot-apache -y sudo certbot --apache


Conclusion

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.

Tags:
aws wordpress hosting ubuntu wordpress installation apache wordpress setup aws ec2 wordpress install wordpress ubuntu aws wordpress tutorial aws apache wordpress launch wordpress on aws ec2 ubuntu apache wordpress wordpress cloud hosting aws aws
AI-Recommended Articles
Was this article helpful?
← Back to Home
Advertisement