0

I created a WordPress site in AWS EC2. it works fine and I can login to my dashboard, then I created a load balancer. I changed my SiteUrl in wp_options to my loadbalancer's dns.

I created an image of that instance. Now I created an auto-scaling group with that image. I'm able to visit my site using the load balancer dns , but I can't login into my dashboard using dns. when I type dns/site/wp-admin it says: wp-login.php was not Found on this server.

I don't what is the problem. kindly help me.

Kush Vyas
  • 5,813
  • 2
  • 26
  • 36
  • You have created image (AMI) which helps you to keep system configuration same but your app actual code inside volume, not image (AMI). – Haresh Chhelana May 29 '18 at 09:29

1 Answers1

1

Edit: To why this is not working because considering you made an image of instance , that means it has two databases (assuming you have not used RDS) now and two servers with two different set of files and db. This should not be the case and might be that would be reason it is not working.

You are taking the wrong approach , you can take advantage of Auto Scaling and Load Balancing if you have designed your site in that way.

This might be a long answer but I hope it clears your understating of how it works or how ideally it should work on AWS

Stateless server

A stateless server is the pre-requisite for building a highly available and scalable infrastructure on AWS. A stateless server does not store any data expect of temporary data like caches.

By default WordPress is storing data in two different ways:

  • MySQL database: articles, comments, users and parts of the configuration are stored in a MySQL database.

  • File system: media files uploaded by the authors are stored on the file system.

If the MySQL database is running on the same EC2 instance as the WordPress application itself, the server is not stateless. Same is true for the media files stored on the file system.

Why is this a problem? Because if the virtual machine becomes unavailable, the data will be unavailable, too. And if you need to add another EC2 instance to handle more traffic all the data will be missing on the additional server

Components that you need to use are :

  • RDS: managed MySQL database
  • S3: media file storage
  • ELB: synchronous decoupling
  • Auto Scaling based on usage

You can refer to this sample architecture for reference: WordPress HA

You can Refer this Blog Post or can use this CloudFormation Template too.

Kush Vyas
  • 5,813
  • 2
  • 26
  • 36
  • Thansk for the answer bro now i have an another doubt please tell me wether this process works or not 1. I installed apache and php in ec2 2. now i create an mysql database in rds and i configure the database name, user name,password in wp-config file 3. my ec2 has full s3 and rds access 4.now i install wordpress and i configure my rds details to it 5.in wordpress dashboard I installed a plugin which will copy the files from uploads folder to s3 bucket ,each and every time a file is uploaded. – Gopirengaraj May 29 '18 at 09:22
  • 6.I think i just configured everything correct 7. now i will create a empty load balancer and I will update my wp_options' siteurl value to the dns 8. now i create a image/snapshot of my ec2 instance 9.then i will create an autoscaling group with that image and in my launch configuration , I will write batch script to load all the files from my s3 to the instances. please tell wether this will work or not bro – Gopirengaraj May 29 '18 at 09:31
  • Refer to this blog : https://premium.wpmudev.org/blog/host-wordpress-multiple-aws-server-instances/ – Kush Vyas May 30 '18 at 06:40