Today we will see how to install WordPress using Amazon CloudFormation option of amazon web service (aws). Amazon CloudFormation will create all necessary resources for running WordPress on AWS. Not only it will create necessary resources it will also take care of managing, updating and provisioning resources in a predictable fashion.
It relives developers and system administrators from creating and managing resource. To use Amazon CloudFormation follow following steps :
Open Amazon Management Console and select CloudFormation as shown below
In CloudFormation, Select Create Stack which will give two options :
- Design Template
- Create New Stack
Select Create New Stack.
Create New Stack will start the wizard for creating new stack and will expect some inputs. First option is to select template option, which presents with option of Design a template or to select existing or saved template from local file or use Amazon s3 template. Amazon provides many sample solution templates.
We will use word press single instance template, Click on view link as shown below
Copy the link from address bar which will be like
https://s3-us-west-1.amazonaws.com/cloudformation-templates-us-west-1/WordPress_Single_Instance.template and click on next.
Next we need to provide stack details like stack name, database, username, password etc… and click next.
Provide tag name and value and click next.
Review all details and click on create.
It will create Amazon EC2 Instance automatically for this.
We can see stack creating in progress
We can see it will create necessary security groups, EC2 instance for us, finally we can see status as CREATE_COMPLETE.
Click on output tab below and open the url in new tab.
Voila! It will open the browser new window with word press installation wizard.
Fill necessary information and click on Install WordPress button at end. Installation will finish in seconds and we will be presented with admin login page.
We can remove login and see home page of the blog.
Before posting we need create the S3 bucket for storing the data about the blog post. Again create a stack with Amazon s3 bucket template. It will create a s3 bucket
Once the stack creation is complete, check for the Ec2 instance created.
Connect EC2 instance using ssh. Once connected install git using
sudo yum -i install git
Clone the wp-static repository from github using following command.
git clone git://github.com/eistrati/WP-static.git $HOME/WP-static
Modify the httpd.conf file to allow permlinks to overide run following commands
sudo sed -i .bak -e ‘s/AllowOverride None /AllowOverride All/g’ /etc/httpd/conf/httpd.conf
Restart the service by issuing following command
sudo service httpd restart
sudo cp $HOME/WP-static/wpstatic.sh /var/www/html/wordpress/;
sudo /bin/sh wstatic.sh
sudo chown -R apache:apache /var/www/html/wordpress
Lets attach bucket for static hosting.
Open Services from Management Console and select s3, it will display all buckets from list select the bucket we created earlier
Select the bucket and click on Properties which will display all properties
Select Static web hosting
Set parameters as shown and copy the endpoint shown above. Open the ssh windows and execute following commands
Enter keys details asked, specify the region. It will create the configuration file in Home directory. Now lets push all the contents to Amazon s3 by excecuting the following commands.
aws s2 cp –recursive –acl public-read wordpress-static s3://<bucket name from above figure>>/wordpress
We can create a cron job to push content every minute to bucket.
Go back to web and login in admin, which will bring up dashboard and now we can create new post.
We are done with setting and running WordPress on AWS.