Category: Aws

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

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

    ✅ 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! 🎉

  • Use Amazon RDS (Managed MySQL Database)

    Use Amazon RDS (Managed MySQL Database)

    Free service

    AWS RDS (Relational Database Service) lets you run MySQL with automatic backups, security, and updates — no server setup needed.

    Pre-requisite: UC2 Server


    ✅ Steps to Create a MySQL Database on Amazon RDS

    1. Go to RDS

    • In AWS Console, search for RDS and click it

    2. Click “Create database”

    3. Choose:

    • Database creation method: Standard Create
    • Engine options: Select MySQL
    • Version: Choose latest (8.x is good)

    4. Settings

    • DB instance identifier: e.g., mydb
    • Master username: admin (or your choice)
    • Master password: Create a strong password

    5. Instance size

    • Select Free tier: db.t3.micro

    6. Storage

    • Keep default (20 GiB is fine for now)

    7. Connectivity

    • VPC: Default
    • Public access: Yes (so you can connect from outside)
    • VPC security group: Create new or select one that allows port 3306 (MySQL)

    8. Additional configuration

    • Database name: e.g., mydatabase
    • Keep defaults for rest (you can adjust later)

    9. Click “Create database”

    Wait a few minutes for the DB to launch.


    ✅ 10. Connect to Your MySQL DB

    Once it’s ready:

    1. Go to Databases > your-db-name
    2. Copy the Endpoint and Port
    3. Connect using a MySQL client:

    From EC2 terminal:

    sudo apt update
    sudo apt install mysql-client -y
    
    mysql -h your-endpoint.rds.amazonaws.com -P 3306 -u admin -p

    Enter your password when prompted.

  • 🚀 How to Launch a New Ubuntu EC2 Server

    🚀 How to Launch a New Ubuntu EC2 Server

    Free AWS Service


    Pre-requisite: AWS Account


    ✅ 1. Sign in to AWS Console

    Go to https://console.aws.amazon.com, and log in.


    ✅ 2. Open the EC2 Dashboard

    • Search for EC2 in the “Find Services” box
    • Click EC2

    ✅ 3. Launch an Instance

    Click the “Launch instance” button.


    ✅ 4. Configure Instance Settings

    🧾 Name and Tags

    • Name your instance: e.g., MyUbuntuServer

    🖥️ Amazon Machine Image (AMI)

    • Select: Ubuntu
      • Choose the latest Ubuntu Server 22.04 LTS (HVM), SSD Volume Type
      • Free-tier eligible

    🧮 Instance Type

    • Choose: t2.micro (free-tier eligible)

    🔐 Key pair (login)

    • If you already have a key pair, select it.
    • If not, click “Create new key pair”:
      • Name it
      • Choose RSA and .pem
      • Download and save the .pem file safely (you’ll need it to SSH later)

    📶 Network settings

    • Allow SSH (port 22) from:
      • My IP (recommended) or
      • Anywhere (less secure)

    💾 Storage

    • Default 8 GiB is fine (can be adjusted)

    ✅ 5. Launch the Instance

    Click “Launch instance”

    Wait a few moments for the instance to start up.


    ✅ 6. Connect to Your Server (via SSH)

    Step 1: Get Public IP

    • In the EC2 dashboard, click your instance
    • Copy the Public IPv4 address

    Step 2: Open Terminal (Linux/macOS) or Git Bash (Windows)

    Navigate to where your .pem file is and run:

    bashCopiarEditarchmod 400 your-key.pem
    ssh -i "your-key.pem" ubuntu@your-ec2-public-ip
    

    Example:

    bashCopiarEditarssh -i "my-aws-key.pem" ubuntu@54.212.123.456
    

    Accept the prompt to connect.


    🎉 You’re now logged in to your Ubuntu EC2 server!