AWS Elastic Beanstalk ( PHP Application )

16 / Jun / 2015 by Ranvijay Jamwal 0 comments

In continuation to my previous Blog on Elastic Beanstalk (Grails Application) , I would now tell you how to deploy a PHP application via Elastic Beanstalk. So, again, we will quickly go through what AWS Elastic Beanstalk does. It is deploying your application in the AWS Cloud without worrying about the infrastructure & making your application production ready within few minutes.

AWS Elastic Beanstalk supports PHP 5.3, 5.4, 5.5, 5.6 & will soon be supporting PHP 6.0. In this blog we will deploy a simple WordPress site & while going through all the necessary steps.

Steps to deploy a PHP application via Elastic Beanstalk :-

1. Go to your AWS Elastic Beanstalk console.

Screenshot from 2015-06-12 13:02:49

2.Create a New Application. Choose the Type of application. For now EB Supports Docker, PHP, Java Tomcat, Ruby etc. For this we will use PHP 5. We will deploy a basic WordPress application.

Screenshot from 2015-06-12 13:05:40

3. Now, Create a new Environment. Choose Web Server.

Screenshot from 2015-06-12 13:04:40

Screenshot from 2015-06-12 13:06:59

Since at this point of time we don’t know the RDS endpoint & the Elastic Beanstalk Environment URL we will choose sample application.

Screenshot from 2015-06-12 13:08:54

5. Select the required settings like Auto-scaled or single Instance Environment, VPC/EC2. You can also select an SNS for reporting changes to your environment. You will have to choose an existing database ( RDS ) or you can create a new one by choosing the DB option. Then if you have chosen to do all this inside a VPC, you need to select the VPC & the subnets.

Screenshot from 2015-06-12 13:09:54Screenshot from 2015-06-12 13:22:49

RDS options :

  • Snapshot : none
  • DB Engine : mysql
  • Instance Class: db.t2.micro (if you want to stay in the free tier)
  • Allocated Storage: 5 to 20 Gb (if you want to stay in the free tier)
  • Availability: Single Availability

Now, VPC configurations for EC2 instances, ELB & RDS. Remember ELB & RDS would require two AZs.

 Screenshot from 2015-06-12 13:24:41
6. After this the environment setup starts & you can check the events in the recent events. Also, other configurations, Logs, Alarms & monitoring can be managed from the Elastic Beanstalk Dashboard itself.
Screenshot from 2015-06-12 14:21:13
7. The last step is to change the endpoint, DB Name, username & password for mysql in wp-config.php which should now look like :-
Screenshot from 2015-06-12 14:22:09
The reason for using “ebdb” is that Elastic Beanstalk by default creates a database with that name in the RDS.
Now, just create a zip of all the WordPress files & upload via Elastic Beanstalk dashboard & you can access previous application versions as well. Just hit the link given in the Elastic Beanstalk dashboard & the following should open.
In my next blog on Elastic Beanstalk we shall talk about how we can use Elastic Beanstalk via API calls with integration with GIT.
FOUND THIS USEFUL? SHARE IT

Leave a Reply

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