{"id":11926,"date":"2014-02-24T16:48:20","date_gmt":"2014-02-24T11:18:20","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=11926"},"modified":"2014-02-27T16:00:38","modified_gmt":"2014-02-27T10:30:38","slug":"deployment-through-git-on-aws-elastic-beanstalk-php-platform","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/deployment-through-git-on-aws-elastic-beanstalk-php-platform\/","title":{"rendered":"Deployment through Git on AWS Elastic Beanstalk (PHP Platform)"},"content":{"rendered":"<p><strong>Elastic Beanstalk<\/strong> is a <strong>PaaS<\/strong> service (Platform as a Service) provided by Amazon. Elastic Beanstalk is gaining limelight as it enables you to setup a complete environment based on the framework you would look out for your application.<\/p>\n<p>It supports almost all the known frameworks, as:<\/p>\n<ul>\n<li>IIS<\/li>\n<li>Node.js<\/li>\n<li>PHP<\/li>\n<li>Python<\/li>\n<li>Ruby<\/li>\n<li>Tomcat<\/li>\n<\/ul>\n<p>The type of environment you can setup with this service can be <strong>Standalone (Single Instance)<\/strong> or a <strong>Load Balanced one supported with AutoScaling<\/strong>\u00a0which automatically manages the server requirement in different traffic situations:<br \/>\n<strong>Increased Traffic<\/strong>: Whenever the traffic on your server increases it would on it\u2019s own, scale up the application to increased number of servers in order to serve the load<br \/>\n<strong>Traffic is stable:<\/strong> When the traffic becomes stable it would automatically terminate the scaled up instances.<\/p>\n<p><strong>In this article<\/strong>, I would be emphasizing more on the PHP framework deployment &amp; setting up the complete environment on Elastic Beanstalk &amp; controlling future deployments via Git from your local server.<\/p>\n<p><strong>Before moving forward<\/strong> you need ensure whether you have the following packages installed on your local server.<\/p>\n<p>1)\u00a0\u00a0\u00a0\u00a0\u00a0 <strong>Git<\/strong>\u00a0 <strong><\/strong><\/p>\n<p>[shell]# yum install git[\/shell]<\/p>\n<p>2)\u00a0\u00a0\u00a0\u00a0\u00a0 <strong>Ruby\u00a0 <\/strong><\/p>\n<p>[shell]# yum install ruby[\/shell]<\/p>\n<p>3) \u00a0 \u00a0\u00a0<strong>JSON Gem\u00a0 <\/strong><strong><\/strong><\/p>\n<p>[shell]# gem install json[\/shell]<\/p>\n<p>Download the Elastic Beanstalk CLI tools from below link on your local server.<br \/>\n<a href=\"https:\/\/aws.amazon.com\/developertools\/6752709412171743\">https:\/\/aws.amazon.com\/developertools\/6752709412171743<\/a><\/p>\n<p>Get the <em>AWSAccessKeyId<\/em> and <em>AWSSecretKeyfrom account dashboard on the AWS Management Console.<\/em><em><\/em><\/p>\n<p><em>Now go the <strong>Elastic Beanstalk<\/strong> through your AWS Management Console. <\/em><em><\/em><\/p>\n<p><em>\u00a0<\/em><\/p>\n<p><em><\/em><em><strong>Creating a PHP Application<\/strong><\/em><\/p>\n<ul>\n<li><em><em><em>You need to create a PHP Application on Elastic Beanstalk Console using <strong>Create New Application.<\/strong><\/em><\/em><\/em><\/li>\n<\/ul>\n<p style=\"padding-left: 30px\"><em><em><\/em><\/em><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/1-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-11929\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/1-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\" alt=\"\" width=\"628\" height=\"113\" \/><\/a><\/p>\n<ul>\n<li>Specify the <strong>Application Name\u00a0<\/strong>e.g., ankush<br \/>\n<a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/2-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\"><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-11930\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/2-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\" alt=\"\" width=\"628\" height=\"206\" \/><\/a><\/li>\n<\/ul>\n<ul>\n<li>Now select the Environment Tier &amp; specify the framework you would like to use (PHP in this case) as I want to create a PHP Application &amp; I want this application to be hosted on a Single instance.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-11931\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/3-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\" alt=\"\" width=\"586\" height=\"287\" \/><\/p>\n<ul>\n<li>On the next Console you have two options.<strong><\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 30px\">Either you can supply your Sample Application Code or upload your own Application Code. For this example, I would be using the Sample PHP Application Code provided by Amazon.<\/p>\n<p style=\"padding-left: 30px\"><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/4-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-11932\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/4-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\" alt=\"\" width=\"628\" height=\"160\" \/><\/a><\/p>\n<ul>\n<li>Specify the <strong>Environment Name\u00a0<\/strong>&amp;\u00a0<strong>Environment URL\u00a0<\/strong>e.g., ankush-env<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-11933\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/5-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\" alt=\"\" width=\"628\" height=\"195\" \/><\/p>\n<ul>\n<li>You can configure Additional Resources for your application like use of RDS &amp; placing the whole environment within a VPC but for this example I would be skipping these configurations by not checking the boxes.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-11934\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/6-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\" alt=\"\" width=\"525\" height=\"212\" \/><\/p>\n<ul>\n<li>Now you now need to specify the <strong>Instance Type<\/strong> for the server on which you would be setting up your environment. As an example I would be taking <strong>t1.micro<\/strong> the least configuration server into picture. You can also specify the <strong>Key Pair<\/strong> if created so before within that region <em>in order to login into the EC2 server<\/em> created by Beanstalk environment.<\/li>\n<\/ul>\n<p style=\"padding-left: 30px\">An <strong>Instance profile<\/strong> role is automatically created by Beanstalk which behaves like a <strong><em>Security Group for your complete environment<\/em><\/strong>.<\/p>\n<p style=\"padding-left: 30px\"><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/7-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-11935\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/7-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\" alt=\"\" width=\"628\" height=\"230\" \/><\/a><\/p>\n<ul>\n<li>At last we have reached to the end of setting up our PHP Application, review the configuration changes you have made &amp; if you are satisfied with the configuration setup of your environment you can launch the same.<\/li>\n<\/ul>\n<ul>\n<li>Wait until the environment gets created &amp; turns <strong>Green<\/strong><\/li>\n<\/ul>\n<p>.<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-11936\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/8-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\" alt=\"\" width=\"628\" height=\"246\" \/><\/p>\n<ul>\n<li>Your environment is ready now. Verify the same by typing<strong><em> yourenvironmentname.elasticbeanstalk.com<\/em><\/strong> on browser.<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-11937\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/9-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\" alt=\"\" width=\"539\" height=\"185\" \/><\/li>\n<\/ul>\n<p>Now we need to <strong>deploy the application present on your local server to Beanstalk &amp; upload the same via Git to your configured environment<\/strong>.<\/p>\n<ul>\n<li>Login to your local server configured with the packages as mentioned before.<\/li>\n<\/ul>\n<ul>\n<li>Save the <em>Elastic Beanstalk CLI tools<\/em> on your local server directory say <strong>\/opt\/<\/strong><\/li>\n<\/ul>\n<ul>\n<li>Unzip the downloaded file.<\/li>\n<\/ul>\n<ul>\n<li>Now create an <strong>index.php<\/strong> file under directory e.g<strong><em>\/var\/www\/ankush<\/em><\/strong><\/li>\n<\/ul>\n<p>[shell]# vi index.php<br \/>\n&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;title&gt;PHP Test&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;?php echo &#8216;&lt;p&gt;My First Elastic Beanstalk Deployment&lt;\/p&gt;&#8217;; ?&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;[\/shell]<\/p>\n<ul>\n<li>We need to initialize Git on our present directory.<\/li>\n<\/ul>\n<p>[shell]# cd \/var\/www\/ankush<br \/>\n# git init[\/shell]<\/p>\n<ul>\n<li>Run AWSDevtools script present under below location<\/li>\n<\/ul>\n<p>[shell]# sh \/opt\/AWS-ElasticBeanstalk-CLI-2.6.0\/AWSDevTools\/Linux\/AWSDevTools-RepositorySetup.sh[\/shell]<\/p>\n<ul>\n<li>Run the following command to set up AWS credentials for this application<\/li>\n<\/ul>\n<p>[shell]# git aws.config[\/shell]<\/p>\n<p><strong>\u00a0<\/strong>This will prompt you to provide the following information.<\/p>\n<p>1)\u00a0\u00a0\u00a0\u00a0\u00a0 AWS Access Key ID<\/p>\n<p>2)\u00a0\u00a0\u00a0\u00a0\u00a0 AWS Secret Key<\/p>\n<p>3)\u00a0\u00a0\u00a0\u00a0\u00a0 AWS Region\u00a0\u00a0 (<em>Region where your enviroment is configured, in my case it is ap-southeast-1<\/em>)<\/p>\n<p>4)\u00a0\u00a0\u00a0\u00a0\u00a0 AWS Elastic Beanstalk Application\u00a0 (<em>Application Name of created environment, in my case <strong>ankush<\/strong><\/em>)<\/p>\n<p>5)\u00a0\u00a0\u00a0\u00a0\u00a0 AWS Elastic Beanstalk Environment\u00a0\u00a0 (<em>Environment Nameof created environment, in my case <strong>ankush-env<\/strong><\/em>)<\/p>\n<ul>\n<li>Once you enter these details correctly, the application is ready to deploy using Git. Make the required changes to the application, commit it, and push, done!<\/li>\n<\/ul>\n<p>[shell]# git add .<br \/>\n# git commit -m &quot;First commit&quot;<br \/>\n# git aws.push[\/shell]<\/p>\n<ul>\n<li>Open <strong><em>yourenvironmentname.elasticbeanstalk.com<\/em><\/strong> on browser, you will see the content you have typed in your <em>index.php<\/em> file.<img decoding=\"async\" loading=\"lazy\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/02\/10-Deployment-through-Git-on-AWS-Elastic-Beanstalk.png\" alt=\"\" width=\"605\" height=\"186\" \/><\/li>\n<\/ul>\n<p><strong>All is done now!!!!! So start hosting your applications on Elastic Beanstalk.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Elastic Beanstalk is a PaaS service (Platform as a Service) provided by Amazon. Elastic Beanstalk is gaining limelight as it enables you to setup a complete environment based on the framework you would look out for your application. It supports almost all the known frameworks, as: IIS Node.js PHP Python Ruby Tomcat The type of [&hellip;]<\/p>\n","protected":false},"author":91,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":4},"categories":[1174],"tags":[1327],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/11926"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/91"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=11926"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/11926\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=11926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=11926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=11926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}