This post sets up a private RDS / MySQL instance free tier level, and an EC2 public instance then installs wordpress.

Create the MySQL instance with NO public access by going into AWS Console RDS->MySQL Community Edition – attributes db.t2.micro. – public no (free tier and not exposed publicly) – give the EC2 / WordPress tier access to your MySQL DB – to be detailed later.

Only trick is adding an inbound rule to MySQL that opens 3306 to the EC2 instance.  One option to do this is assign the Security Group used for the EC2 instance to an inbound rule on the MySQL security group.  Better ways are not free – but more secure – front EC2 with a load balancer – which as a fixed domain name, or use a fixed IP / Elastic IP.

Another way to do it – is just put it all on EC2 – and install MySQL manually.  That is easy enough but, you don’t get the MySQL / RDS auto backups and options to go multi-zone – that come with a separate RDS / MySQL tier diagramed below.

Code to setup the EC2 publicly exposed WordPress / Apache Tier:

 yum update -y
 yum install httpd php php-mysql stress -y
 cd /etc/httpd/conf
 cp httpd.conf httpdconfbackup.conf
 vi httpd.conf - find the 2nd AllowOverride (beneath <Directory "/var/www/html">)  - vi :set ic /allowover to find it - 2nd one - change "none" to "All".
 # no - don't do this -= wget
 cd /var/www/html
 tar -xzf latest.tar.gz
 cp -r wordpress/* /var/www/html/
 rm -rf wordpress
 rm -rf latest.tar.gz
 chmod -R 755 wp-content
 chown -R apache:apache wp-content
 service httpd start
 chkconfig httpd on

Of course you can provide a much more resilient architecture with elastic load balancing and failover databases etc.  But that is for another post.

Well I had a little trouble setting this up… the last step is to put your connect info into:


and the database name was defaulting to “innodb” which as not clear until I went thru the pain of connecting with mysql workbench remotely to see the DBs… more on this later in detail…

don’t forget to restart apache after changing wp-config.php

either for RHEL 6 and 7 respectively

service httpd restart


systemctl restart httpd

More from LonzoDB on AWS

Leave a Reply

Your email address will not be published. Required fields are marked *