Launching a WordPress site on Amazon EC2 gives you the flexibility and power of cloud infrastructure—with complete control over performance, scalability, and cost. But with that control comes the responsibility to harden your server against vulnerabilities. This guide walks you through setting up WordPress with NGINX and SSL on AWS EC2 using Bitnami, followed by a series of security best practices to protect your site from the start.
Why Use Amazon EC2 to Host WordPress?
If you're wondering why someone would go through the effort of launching a custom WordPress server on Amazon EC2 instead of using shared hosting or a managed WordPress provider, the answer comes down to control, scalability, and performance.
Here’s why Amazon EC2 stands out — especially for users who want a hardened, self-managed WordPress environment:

1. Reliability (99.9% Uptime SLA)
Amazon EC2 offers 99.9% availability per region, backed by one of the most redundant and globally distributed infrastructures in the world. This means your website is more resilient to outages than traditional shared hosting environments. When uptime matters (e.g., eCommerce, lead-gen sites, client portals), EC2 offers peace of mind.
2. Built-In Security with Amazon VPC
EC2 integrates with Amazon VPC (Virtual Private Cloud), giving you full control over your network environment. You can configure firewalls, restrict traffic by IP, and even isolate your instance entirely. Combined with Bitnami’s hardened WordPress stack and best practices like SSH key authentication and SSL encryption, your setup becomes far more secure than a basic WordPress host.
3. Flexibility to Customize Everything
With EC2, you control the entire stack — from the operating system and web server (NGINX) to PHP versions and file permissions. Need a custom cron job? Special caching config? A non-standard WordPress architecture? EC2 makes it possible, unlike locked-down shared or managed platforms.
4. Cost Control and Savings
You only pay for the compute power and storage you use. For low-to-moderate traffic sites, a t2.micro or t3a.micro instance under the AWS Free Tier is often sufficient — especially when optimized. And when traffic grows, EC2 lets you scale up or out without migrating your site.
Want to shut down your dev instance at night? EC2 lets you stop billing when you're not using it. You’re in control.
5. Complete Computing Solution
Amazon EC2 isn't just web hosting — it's a full computing platform. You can:
- Host APIs
- Run background workers
- Deploy scripts and automation
- Combine with RDS for external databases
- Integrate with S3 for media storage
- Use CloudWatch for performance monitoring and alerts
This makes EC2 ideal for custom workflows, plugins, and integrations that go beyond traditional WordPress.
6. Elastic Web-Scale Infrastructure
One of the most powerful aspects of EC2 is the ability to scale on demand. Whether it's auto-scaling behind a load balancer or upgrading instance types for performance spikes, EC2 makes it possible to meet growing traffic needs without moving to a new platform.
7. Completely Controlled Environment
You’re not just configuring WordPress — you’re configuring your entire environment, down to the OS. This means:
- You decide what services run
- You choose when updates are applied
- You implement your own security policies
- You control logging, performance, and access
That level of control is what makes EC2 the preferred choice for developers, agencies, and technical teams that want to build with intention — not limitations.
If your business requires more than "just hosting" — if you value performance, security, and scalability — Amazon EC2 is a serious contender. Yes, it takes more setup, but with the right configuration (like the one covered in this guide), the long-term benefits are significant.
Step 1: Launch a Bitnami WordPress Instance on EC2
- Log in to your AWS Console, navigate to EC2, and click Launch Instance.
- Under Application and OS Images (AMI), choose AWS Marketplace and search for:
WordPress with NGINX and SSL Certified by Bitnami and Automattic
- Select a t2.micro instance (Free Tier eligible) and configure your key pair and security group:
- Allow SSH (port 22) from your IP
- Allow HTTP (80) and HTTPS (443) from anywhere
- Launch the instance and wait for it to initialize.
Step 2: SSH into the Server
chmod 400 your-key.pem
ssh -i "your-key.pem" bitnami@your-ec2-public-ip
This logs you in as the Bitnami user.
Step 3: Retrieve WordPress Login Credentials
Once connected, run:
cat /home/bitnami/bitnami_credentials
Log in to http://your-ec2-public-ip/wp-admin
using the provided username and password.
Step 4: Point Your Domain to the EC2 Instance
At your domain registrar (e.g., Namecheap, GoDaddy), create the following DNS records:
Allow time for DNS propagation.
Step 5: Enable SSL with Bitnami's bncert-tool
Once your domain resolves to the instance, run:
sudo /opt/bitnami/bncert-tool
Follow the prompts to:
- Enter your domain name(s)
- Redirect HTTP to HTTPS
- Automatically renew your SSL certificate
Step 6: Update WordPress URL Settings
In the WordPress dashboard, go to Settings > General and update:
- WordPress Address:
https://yourdomain.com
- Site Address:
https://yourdomain.com
Alternatively, edit wp-config.php
:
sudo nano /opt/bitnami/wordpress/wp-config.php
Add:
define('WP_HOME', 'https://yourdomain.com');
define('WP_SITEURL', 'https://yourdomain.com');
Step 7: Redirect HTTP to HTTPS in NGINX
If bncert-tool
didn’t automatically create the redirect:
1. Open your NGINX server block:
sudo nano /opt/bitnami/nginx/conf/server_blocks/wordpress-server-block.conf
2. Add this before the main server block:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
return 301 https://$host$request_uri;
}
3. Restart NGINX:
sudo /opt/bitnami/ctlscript.sh restart nginx
Step 8: Replace Default Admin Username and Email (Using WP-CLI)
1. Connect via SSH and navigate to WordPress:
cd /opt/bitnami/wordpress
2. List users and find the one with ID 1
:
sudo wp user list --allow-root
3. Create a new admin user:
sudo wp user create myadmin your@email.com --role=administrator --user_pass=StrongPassword123 --allow-root
4. Delete the default user:
sudo wp user delete 1 --allow-root
5. Change the admin email:
sudo wp option update admin_email your@email.com --allow-root
Step 9: Harden WordPress with Security Best Practices
Disable File Editing
In wp-config.php
, add:
define('DISALLOW_FILE_EDIT', true);
define('DISALLOW_FILE_MODS', true); // Also disables plugin/theme install via dashboard
Security Headers (Add to NGINX Config)
Inside your NGINX server block:
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
add_header Referrer-Policy "no-referrer-when-downgrade";
add_header Permissions-Policy "geolocation=(), microphone=()";
add_header Content-Security-Policy "default-src 'self' https: data: 'unsafe-inline' 'unsafe-eval';";
Block XML-RPC (Unless Needed)
location = /xmlrpc.php {
deny all;
}
Warning: This configuration may already be part of your file, so you don't want to include this line more than once, or you will get an error when trying to restart.
Prevent User Enumeration
if ($query_string ~ "author=\\d") {
return 403;
}
Restrict Access to Sensitive Files
location ~* wp-config.php {
deny all;
}
location ~ /\. {
deny all;
}
Disable Directory Indexing
Make sure your location /
block includes:
autoindex off;
try_files $uri $uri/ /index.php?$args;
Warning: the second line, 'try_files' may already be part of your file, so you don't want to include this line more than once, or you will get an error when trying to restart.
After editing your server block:
sudo /opt/bitnami/nginx/sbin/nginx -t
sudo /opt/bitnami/ctlscript.sh restart nginx
Step 10: Additional Hardening Recommendations
- Install a security plugin like Patchstack, Solid Security Pro and Limit Login Attempts Reloaded
- Use strong passwords and enable 2FA
- Keep WordPress core, plugins, and themes updated
- Use Cloudflare or AWS WAF to block malicious traffic
- Set up regular backups using plugins or AMI snapshots
You’re Done: A Production-Ready, Secure WordPress Site
At this point, your WordPress site is:
- Running on a hardened Bitnami NGINX stack
- Protected with SSL, security headers, and blocked attack vectors
- Stripped of default credentials and insecure features
- Tuned for uptime, performance, and long-term stability
With EC2, you get control. With Bitnami, you get simplicity. And with these security practices, you get peace of mind.
Preventing SSL Expiration Issues on EC2: Don't Let Your Site Go Dark
One of the most common causes of unexpected downtime we’ve seen with EC2-hosted WordPress sites is expired SSL certificates.
Let’s Encrypt SSL certificates — commonly installed with tools like Bitnami’s bncert-tool
— expire every 90 days. If the auto-renewal fails silently (which happens more often than you’d think), your site can suddenly become inaccessible to visitors and show a browser security warning. That’s not just a bad look — it can also kill your conversion rates.
Why SSL Renewal Fails on EC2
Some typical reasons we’ve seen:
bncert-tool
was never set to auto-renew, or the cron job failed- DNS issues or firewall settings prevented domain validation
- The domain name was changed but the certificate wasn’t updated
- The EC2 instance clock drifted (breaking time-based authentication)
- Permissions or ownership issues blocked renewal scripts
How to Prevent SSL Certificate Expiration on EC2
Here’s how to ensure your certificates stay valid and your site stays online:
1. Verify Auto-Renewal is Configured
When using the Bitnami bncert-tool
, it should configure a cron job for renewal. Check it:
sudo crontab -l
Look for a line like:
0 0 * * * /opt/bitnami/letsencrypt/scripts/renew-certificate.sh 2> /dev/null
If it's missing, you can manually add it, or re-run bncert-tool
:
sudo /opt/bitnami/bncert-tool
2. Monitor Your Certificate Expiration
Use this command to check the certificate’s expiry date:
sudo openssl x509 -in /opt/bitnami/letsencrypt/certificates/YOURDOMAIN.crt -text -noout | grep "Not After"
Or use an online tool like SSL Labs to monitor from outside.
3. Set Up Email Alerts or Use Cloud Monitoring
If you use AWS CloudWatch or a third-party service, set an alert for SSL expiration. Tools like:
- Certbot expiry hooks
- UptimeRobot or Better Stack Uptime (SSL expiry alerts)
- AWS CloudWatch + Lambda functions (advanced)
These can help ensure you get notified before the certificate becomes a problem.
4. Consider Using AWS Certificate Manager + Load Balancer
For more advanced or multi-site setups, you can use AWS Certificate Manager (ACM) with an Application Load Balancer (ALB) to offload SSL termination and let Amazon handle renewals. This takes more setup but completely removes the risk of expiry-related downtime.
5. Renew Manually If Needed (Quick Fix)
If your SSL has already expired or you’re unsure, you can reissue a certificate manually:\
sudo /opt/bitnami/bncert-tool
Or, if using Certbot:
sudo certbot renew
Pro Tip: Schedule Monthly Maintenance Checks
Even with automation in place, we recommend adding a monthly calendar reminder to SSH in and check:
- SSL certificate expiry
- Disk space
- System updates
- Plugin/theme security
This lightweight routine can save hours of downtime and lost trust.
Don’t wait until Chrome starts warning your customers that your site is “Not Secure.” A little SSL maintenance now prevents bigger headaches later.
Want Help Setting Up a WordPress Alternative?
Setting up WordPress on EC2 with hardened security is powerful — but it’s also a lot of work. Between configuring servers, managing SSL certificates, restricting access, and monitoring for vulnerabilities, you’re essentially maintaining a full DevOps pipeline for a single site.
For many businesses, that level of control is overkill. And it often comes at the cost of speed, flexibility, and simplicity.
So what’s the alternative?
Try a Headless CMS with Modern Hosting
Instead of hosting your own WordPress server, consider switching to a headless CMS like Storyblok, Contentful, or even a no-code-friendly solution like Webflow. These platforms separate your content management from the front-end delivery — allowing you to:
- Eliminate plugin security issues
- Reduce website maintenance Costs
- Avoid managing PHP, MySQL, or server-level configuration
- Use modern, high-performance frontends like Astro, Next.js, or Vue
- Deploy to platforms like Vercel or Netlify, with automatic SSL and zero maintenance
- Easily scale to handle traffic spikes without tuning your infrastructure
With a headless or no-code platform, your marketing team can update content without waiting on developers, and your developers can build blazing-fast, secure websites without being held back by legacy architecture.
Why Clients Are Moving Away from WordPress
We’ve helped clients make the move from traditional WordPress installs to headless CMS platforms because they’re:
- Frustrated with constant updates and compatibility issues
- Tired of security risks from third-party plugins
- Looking for faster performance and better SEO scores
- Ready to future-proof their digital presence
Done-for-You Modern Architecture
Our team specializes in designing and building modern web solutions using:
- Astro + Storyblok + Vercel (ultra-fast and fully customizable)
- Webflow CMS (for marketers who need speed and ease of use)
- Astro + Contentful + Vercel (for enterprise-grade scale)
We handle the full setup, from planning your content model to configuring your CDN and performance monitoring — so you get the benefits of modern architecture without the technical complexity.
If you’re ready to move beyond server maintenance, plugin management, and manual security patches, let’s talk. We’ll help you choose the right stack for your needs and migrate with minimal downtime.
Contact us to learn how a modern, headless CMS can simplify your life while improving performance, security, and scalability.