Category: RDS

  • ๐Ÿ› ๏ธ 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.