Case Study: How I Restored a Down Website and Optimized AWS Infrastructure for an E-commerce Client in 20 Hrs
Shyam Varma
Business Startup Consultant, Full Stack Developer, Digital Marketer & a Mentor For Aspiring Professionals
Introduction:
Problem/Challenge:
Solution:
With 14+ years of experience in the tech industry, I took on the dual role of DevOps Engineer and Project Manager, ensuring that the client understood every technical decision and its impact on their budget. I provided a clear, transparent consultation on the best way to optimize the website, despite slightly increasing AWS costs due to necessary resource upgrades.
Here’s how I approached it:
Implementation:
For those who want to understand how and what steps were performed, I have prepared a tutorial or steps based on actions taken. Here's a complete step-by-step list of all the commands, including permissions setup, AWS configuration, backup and restore commands, file operations, and more. I have organized them by functionality for easier reference:
1. AWS Configuration
Configure AWS CLI:
aws configure
This command will prompt you to input your AWS Access Key, Secret Key, Region, and Output format.
Pull a file from AWS S3 Bucket:
aws s3 cp s3://bucket-name/wp-content_datetime.zip /tmp/wp-content_datetime.zip
This copies the wp-content_datetime.zip file from your S3 bucket to the /tmp directory.
2. WordPress File Permissions
Set Ownership for WordPress Files:
Make sure that the ownership of the WordPress files is set correctly:
sudo chown -R bitnami:daemon /opt/bitnami/wordpress/
Set Correct Permissions for Files and Directories:
Set Correct Permissions for wp-config.php:
3. Backup and Restore WordPress
Remove All Files from wp-content Directory:
sudo rm -rf /opt/bitnami/wordpress/wp-content/*
Extract a WordPress Backup Zip File:
To extract the wp-content_datetime.zip file from /tmp to the wp-content directory:
sudo unzip /tmp/wp-content_datetime.zip -d /opt/bitnami/wordpress/wp-content/
Backup WordPress Plugins Directory:
To copy all plugins from a backup directory (bk_plugins) to the active plugins directory:
sudo cp -r /path/to/bk_plugins/* /path/to/plugins/
Zip WordPress Directory and Move to Temp:
To create a zip file of the WordPress directory and move it to the /tmp directory:
sudo zip -r /tmp/wordpress_backup.zip /path/to/wordpress/
4. Swap Configuration
Create Swap File:
Create a 2 GB swap file:
sudo fallocate -l 2G /swapfile
If fallocate is not available:
sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
Set Correct Permissions for Swap File:
sudo chmod 600 /swapfile
领英推荐
Set Up the Swap File:
sudo mkswap /swapfile
Activate Swap File:
sudo swapon /swapfile
Make Swap Permanent (Add to /etc/fstab):
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Optional: Adjust Swappiness (System Tuning):
sudo sysctl vm.swappiness=10
To make the swappiness setting permanent:
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
6. Installing Software (htop)
Install htop on Bitnami VPS:
7. Useful Monitoring Commands
Check CPU and Memory Usage:
top
or use htop for a better user interface:
htop
Check Free Memory and Swap:
free -h
8. Tunneling for phpMyAdmin Access
Create an SSH Tunnel with PuTTY on Windows:
Once connected, you can open phpMyAdmin in your browser by visiting:
https://127.0.0.1:8888/phpmyadmin
Login to phpMyAdmin Using RDS Database:
Since you're using an RDS instance, you can use the database credentials from your wp-config.php file to log into phpMyAdmin.
9. Additional WordPress Commands
Deactivate All WordPress Plugins:
sudo wp plugin deactivate --all --path=/path/to/wordpress/
These commands should cover all the steps required for managing your Bitnami WordPress instance on AWS, including backups, restores, file management, and database optimization. Let me know if you need any further assistance or if additional steps need to be included!
Results:
Quantifiable Outcomes:
Client Impact: The client’s site was fully restored, with significantly faster admin functionality. Although their AWS bill increased, the benefits far outweighed the costs, as the site now runs smoothly and efficiently.
Challenges Faced & Overcome:
Conclusion & Key Takeaways:
Summary:
Now for the important question:
So, guys, what do you think? Did I do a good job? ?? I’d love to hear your thoughts!