Leanpub Header

Skip to main content

Complete Guide to Self-Hosted WordPress on AWS

Build, secure, and run a production WordPress site on EC2

Complete Guide to Self-Hosted WordPress on AWS
This book is 100% completeLast updated on 2026-09-21

Managed WordPress hosting is convenient until the bill grows or something breaks and you cannot see why. This book takes you from an empty AWS account to a secured, monitored, backed-up production site, with every command tested on a real server and every step explained. By the end you will know how to run it, protect it, restore it, and fix it at three in the morning.

Minimum price

$34.99

$34.99

You pay

Author earns

$

Also available for 2 book credits with a Reader Membership

PDF
EPUB
About

About

About the Book

Complete Guide to Self-Hosted WordPress on AWS is a hands-on, command-by-command manual for standing up a production-grade WordPress site on Amazon EC2 and running it the way a hosting provider would: hardened, monitored, backed up, and maintained. It is not a book about writing posts or picking a theme. It is about the infrastructure underneath — the AWS account, the network, the LAMP stack, the security layers, and the maintenance habits that separate a real production system from a tutorial project that breaks the first time something goes wrong.

The book is self-contained. You will not be sent off to piece together five outdated blog posts and a stale AWS doc page to get a working answer. Every chapter builds on the last, using the same instance, the same domain, and the same working configuration.

Inside, you will:

- Decide whether self-hosting is right for you, and understand the tradeoffs against managed WordPress hosting
- Set up an isolated AWS sandbox: a VPC, security groups, and an EC2 instance with proper SSH access
- Install and configure Apache, MySQL, PHP, and WordPress using WP-CLI, and tune PHP-FPM for real traffic
- Configure Apache virtual hosts, DNS, and Cloudflare, then wire up SSL end to end
- Harden the site against attacks with Apache and NGINX-style rules, a Cloudflare WAF, and login security including two-factor authentication
- Set up Redis object caching for performance, and Amazon SES for transactional email
- Read and rotate logs, enable WP_DEBUG properly, and set up monitoring and alerts so you find out about problems before your visitors do
- Version-control your site, take real backups, and practice restoring from them before you actually need to
- Learn how to migrate an existing WordPress site onto this setup
- Know what to check first if you suspect you've been hacked, and how to recover
- Handle the unglamorous but essential parts: routine maintenance, plugin hygiene, and scaling up as traffic grows

The appendices give you a MySQL cheat sheet, a WP-CLI cheat sheet, NGINX equivalents for every Apache command in the book, complete configuration files, and a one-page runbook you can tape next to your monitor.

Who this is for: developers, freelancers, and consultants who set up WordPress for clients or their own business and want to stop paying for managed hosting or explaining downtime they can't diagnose. It's also a strong fit for a computer science student who wants a real, defensible production system on their resume instead of another tutorial project. Basic command-line comfort is assumed; everything else — AWS, Linux administration, and WordPress internals — is taught from the ground up.

By the end, you will be able to provision, secure, and operate a commercial-grade WordPress installation entirely on your own — the same work managed hosting providers charge you for every month.

About the author: Siddharth Jain is a software developer with more than 15 years of experience in the tech industry across Microsoft, Uber, Johnson & Johnson, and Cisco. He is also the author of Programming Hyperledger Fabric: Creating Enterprise Blockchain Applications and runs his own WooCommerce based web store at https://www.sidstick.com/. More information about him can be found on his Linkedin profile: https://www.linkedin.com/in/awargi/

Share this book

Author

About the Author

Siddharth Jain

Siddharth Jain is a software developer with more than 15 years of experience in the tech industry across Microsoft, Uber, Johnson & Johnson and Cisco. He is also the author of Programming Hyperledger Fabric: Creating Enterprise Blockchain Applications. He runs his own WooCommerce powered art gallery at https://www.sidstick.com/. More information about him can be found on his Linkedin profile at https://www.linkedin.com/in/awargi/.

Contents

Table of Contents

  • Preface
  • 1. Managed vs. Self-Hosted WordPress
  • 2. Your AWS Account, Workstation, and Domain
  • 3. Network Isolation with a VPC
  • 4. The Firewall: Security Groups
  • 5. Launching the EC2 Instance
  • 6. First Login: Swap, Updates, SSH, and Time
  • 7. Apache, MySQL, and PHP
  • 8. PHP-FPM and the Event MPM
  • 9. Installing WordPress with WP-CLI
  • 10. Apache Configuration: Virtual Hosts and .htaccess
  • 11. DNS and Cloudflare
  • 12. SSL End to End
  • 13. Configuring Cloudflare WAF
  • 14. Cloudflare Performance and Analytics
  • 15. Redis Object Cache
  • 16. Email with FluentSMTP and Amazon SES
  • 17. Replacing wp-cron with System Cron
  • 18. Backups: Snapshots, Dumps, and Offsite
  • 19. Restoring from Backup
  • 20. Version Control for Your Site
  • 21. WordPress Hardening
  • 22. Login Security and Two-Factor Authentication
  • 23. Plugin Management and Hygiene
  • 24. Logs: Reading, Rotating, and WP_DEBUG
  • 25. Monitoring and Alerting
  • 26. Routine Maintenance and Updates
  • 27. Scaling Up: Instance Size and Disk
  • 28. Migrating an Existing Site
  • 29. If You Suspect You Have Been Hacked
  • Appendix A. MySQL Cheat Sheet
  • Appendix B. WP-CLI Cheat Sheet
  • Appendix C. NGINX Equivalents
  • Appendix D. PHP Cheat Sheet
  • Appendix E. One-Page Runbook

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub