This is a project idea that I first saw in a lab at qwiklabs.com in preparation for my SysOps Administrator – Associate Certification.
The idea is to use any live wordpress site to generate the static html files to be served from S3 hosting instead of the typical host service. One might do this for either cost savings or security – or both!
I implemented this using the standard Amazon Linux AMI to launch an EC2 instance. The boot script installs and launches php, mysql, and apache. Then I manually set up mySQL and WordPress via the standard deployment process. After testing with a few posts, install a plugin called “Simply Static”. Running this will create a zip file containing all of the WordPress content as static html which can then be uploaded to an S3 bucket with hosting turned on. Now stop the instance and stop paying for hosting it 24/7. This will have the same look and feel as the live version – minus searching and posting functions that would require php and MySQL to function (and be hacked).
When an update is needed simply start the WordPress instance only long enough to make the changes and generate new static files and export the WP content!
One issue is that WordPress stores the IP address into MySQL – causing issues if the IP changes, which it will unless you use a fixed IP such as an Elastic IP. Unfortunately the resting Elastic IP costs more than a running t2.micro instance does! I think a startup script could update the DB with the current IP. A minor issue is the cost of keeping the EBS store around. A potential fix would be to dump MySQL and export WordPress data to S3 and load it back upon launching the instance.
That was an interesting project. And the result is this very site you are viewing right now!