🛠️ Step-by-Step: Install Caddy + WordPress on Ubuntu EC2

·

, , , , ,
wordpress

✅ 0. Prerequisites


✅ 1. Update System

sudo apt update && sudo apt upgrade -y

✅ 2. Install PHP + Dependencies

WordPress needs PHP and extensions:

sudo apt install php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-zip php-soap php-intl php8.3-fpm unzip curl -y

✅ 3. Install Caddy (Official Script)

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https

curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/caddy-stable.asc

curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list

sudo apt update
sudo apt install caddy -y

Caddy will auto-start and be set as a systemd service.


✅ 4. Download and Setup WordPress

📁 Go to web root

cd /var/www
sudo mkdir wordpress
cd wordpress

⬇️ Download WordPress

sudo curl -O https://wordpress.org/latest.zip
sudo unzip latest.zip
sudo mv wordpress/* .
sudo rm -rf wordpress latest.zip

🔐 Set permissions

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

✅ 5. Create a database

# admin or your rds mysql user
sudo mysql -h your-rds-endpoint.amazonaws.com -u admin -p

CREATE DATABASE wordpress;

CREATE USER 'wp_user'@'%' IDENTIFIED BY 'strong_password';

GRANT ALL PRIVILEGES ON 'wordpress'.* TO 'wp_user'@'localhost';

FLUSH PRIVILEGES;

EXIT


✅ 6. Configure Caddy

📄 Edit the Caddyfile

sudo nano /etc/caddy/Caddyfile

Example config:

yourdomain.com {
    root * /var/www/wordpress    
    file_server    php_fastcgi localhost:9000
}

Replace yourdomain.com with your domain or public IP (e.g., ec2-3-85-123-45.compute-1.amazonaws.com)

If you have a domain, you must point it to the EC2 public address in the DNS config of your provider.

If you’re not using a domain yet, Caddy won’t get HTTPS — use plain HTTP by setting:

:80 {
    root * /var/www/wordpress    file_server    php_fastcgi localhost:9000    
}

✅ 7. Restart Services

sudo systemctl reload caddy
sudo systemctl restart php8.3-fpm

✅ 8. Open Ports in Security Group

In the EC2 Security Group:

  • Allow HTTP (80)
  • Allow HTTPS (443) (if using domain + SSL)

✅ 9. Access WordPress

Now go to:

http://your-ec2-public-ip

or

https://yourdomain.com

You’ll see the WordPress setup screen!

Just finish the configuration process answering the requested information!

And Voalá! You have your personal WordPress up and running! 🎉