AWS Security ChangesHomeSearch

AWS elasticbeanstalk medium security documentation change

Service: elasticbeanstalk · 2025-06-07 · Security-related medium

File: elasticbeanstalk/latest/dg/php-quickstart.md

Summary

Updated PHP quickstart tutorial with restructured steps, added explicit warnings about non-production use, simplified prerequisites, and revised deployment/cleanup instructions.

Security assessment

Added explicit 'Warning - Not for production use!' section and repeated cautions about example applications. This directly addresses security by warning against using unhardened demo code in production environments.

Diff

diff --git a/elasticbeanstalk/latest/dg/php-quickstart.md b/elasticbeanstalk/latest/dg/php-quickstart.md
index 64539f7ef..ff54e6fd8 100644
--- a//elasticbeanstalk/latest/dg/php-quickstart.md
+++ b//elasticbeanstalk/latest/dg/php-quickstart.md
@@ -5 +5 @@
-Your AWS accountPrerequisitesStep 1: Create a PHP applicationStep 2: Run your application locallyStep 3: Deploy your PHP application with the EB CLIStep 4: Run your application on Elastic BeanstalkStep 5: Clean upAWS resources for your applicationNext stepsDeploy with the console
+Your AWS accountPrerequisitesStep 1: Create a PHP applicationStep 2: Run your application locallyStep 3: Initialize and deploy your PHP applicationStep 4: Browse your cloud applicationStep 5: Update and redeploy your applicationClean upNext steps
@@ -9,28 +9 @@ Your AWS accountPrerequisitesStep 1: Create a PHP applicationStep 2: Run your ap
-This QuickStart tutorial walks you through the process of creating a PHP application and deploying it to an AWS Elastic Beanstalk environment.
-
-###### Note
-
-This QuickStart tutorial is intended for demonstration purposes. Do not use the application created in this tutorial for production traffic.
-
-###### Sections
-
-  * Your AWS account
-
-  * Prerequisites
-
-  * Step 1: Create a PHP application
-
-  * Step 2: Run your application locally
-
-  * Step 3: Deploy your PHP application with the EB CLI
-
-  * Step 4: Run your application on Elastic Beanstalk
-
-  * Step 5: Clean up
-
-  * AWS resources for your application
-
-  * Next steps
-
-  * Deploy with the Elastic Beanstalk console
-
+In the following tutorial, you'll learn how to create and deploy a sample PHP application to an AWS Elastic Beanstalk environment using the EB CLI.
@@ -37,0 +11 @@ This QuickStart tutorial is intended for demonstration purposes. Do not use the
+###### Warning - Not for production use!
@@ -38,0 +13 @@ This QuickStart tutorial is intended for demonstration purposes. Do not use the
+Examples are intended for demonstration only. Do not use example applications in production.
@@ -42,3 +17 @@ This QuickStart tutorial is intended for demonstration purposes. Do not use the
-If you're not already an AWS customer, you need to create an AWS account. Signing up enables you to access Elastic Beanstalk and other AWS services that you need.
-
-If you already have an AWS account, you can move on to Prerequisites.
+If you're not already an AWS customer, you need to create an AWS account to use Elastic Beanstalk.
@@ -119,7 +92 @@ For instructions, see [ Add groups](https://docs.aws.amazon.com/singlesignon/lat
-To follow the procedures in this guide, you will need a command line terminal or shell to run commands. Commands are shown in listings preceded by a prompt symbol ($) and the name of the current directory, when appropriate.
-    
-    
-    ~/eb-project$ this is a command
-    this is output
-
-On Linux and macOS, you can use your preferred shell and package manager. On Windows you can [install the Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to get a Windows-integrated version of Ubuntu and Bash.
+  * Elastic Beanstalk Command Line Interface - For installation, see [Install EB CLI with setup script (recommended)](./eb-cli3.html#eb-cli3-install).
@@ -127 +94 @@ On Linux and macOS, you can use your preferred shell and package manager. On Win
-### EB CLI
+  * PHP - Install PHP on your local machine by following [Installation and Configuration](https://www.php.net/manual/en/install.php) instructions on the PHP website.
@@ -129 +95,0 @@ On Linux and macOS, you can use your preferred shell and package manager. On Win
-This tutorial uses the Elastic Beanstalk Command Line Interface (EB CLI). For details on installing and configuring the EB CLI, see [Install the Elastic Beanstalk Command Line Interface](./eb-cli3-install.html) and [Configure the EB CLI](./eb-cli3-configuration.html).
@@ -131 +96,0 @@ This tutorial uses the Elastic Beanstalk Command Line Interface (EB CLI). For de
-### PHP
@@ -133 +97,0 @@ This tutorial uses the Elastic Beanstalk Command Line Interface (EB CLI). For de
-Install PHP on your local machine by following [Installation and Configuration](https://www.php.net/manual/en/install.php) on the PHP website.
@@ -137 +101 @@ Install PHP on your local machine by following [Installation and Configuration](
-In this example, we create a _Hello World_ PHP application. PHP applications can be created with minimal overhead.
+For this quick start, you will create a _Hello World_ PHP application.
@@ -145 +109 @@ Create a project directory.
-Next, create an `index.php` file in the project directory. This file is served by default when running PHP.
+Next, create an `index.php` file in the project directory and add the following code.
@@ -146,0 +111 @@ Next, create an `index.php` file in the project directory. This file is served b
+###### Example `index.php`
@@ -148,2 +112,0 @@ Next, create an `index.php` file in the project directory. This file is served b
-    ~/eb-php/
-    |-- index.php
@@ -151 +114,3 @@ Next, create an `index.php` file in the project directory. This file is served b
-Add the following content to your `index.php` file.
+    <?php
+      echo "Hello from a PHP application running in Elastic Beanstalk!";
+    ?>
@@ -153 +117,0 @@ Add the following content to your `index.php` file.
-###### Example `~/eb-php/index.php`
@@ -154,0 +119 @@ Add the following content to your `index.php` file.
+## Step 2: Run your application locally
@@ -156 +121 @@ Add the following content to your `index.php` file.
-    echo "Hello Elastic Beanstalk! This is a PHP application.";
+Use the following command to run your application locally.
@@ -158 +122,0 @@ Add the following content to your `index.php` file.
-## Step 2: Run your application locally
@@ -160 +124 @@ Add the following content to your `index.php` file.
-Run the following command to run your application locally.
+    php -S localhost:5000
@@ -161,0 +126 @@ Run the following command to run your application locally.
+Open a browser to [`http://localhost:5000`](http://localhost:5000).
@@ -163 +128 @@ Run the following command to run your application locally.
-    ~/eb-php$ php -S localhost:5000
+You should see your hello message in the browser and log messages in your terminal.
@@ -165 +130 @@ Run the following command to run your application locally.
-Enter the URL address `http://localhost:5000` in your web browser. The browser should display “Hello Elastic Beanstalk! This is a PHP application.”
+Stop the local server by entering `Control+c`, so you can deploy the Elastic Beanstalk.
@@ -167 +132 @@ Enter the URL address `http://localhost:5000` in your web browser. The browser s
-## Step 3: Deploy your PHP application with the EB CLI
+## Step 3: Initialize and deploy your PHP application
@@ -169 +134 @@ Enter the URL address `http://localhost:5000` in your web browser. The browser s
-Run the following commands to create an Elastic Beanstalk environment for this application.
+Next, you will deploy your application to an _environment_ using the Elastic Beanstalk console or the EB CLI. For this tutorial, you'll use the EB CLI with the interactive option to initialize an environment. 
@@ -171 +136 @@ Run the following commands to create an Elastic Beanstalk environment for this a
-###### To create an environment and deploy your PHP application
+###### To initialize your environment and create an environment
@@ -173 +138 @@ Run the following commands to create an Elastic Beanstalk environment for this a
-  1. Initialize your EB CLI repository with the **eb init** command.
+  1. Run the following **init** command.
@@ -175 +140 @@ Run the following commands to create an Elastic Beanstalk environment for this a
-        ~/eb-php$ eb init -p php php-tutorial --region us-east-2
+        eb init -i
@@ -177 +142 @@ Run the following commands to create an Elastic Beanstalk environment for this a
-This command creates an application named `php-tutorial` and configures your local repository to create environments with the latest PHP platform version.
+The init command creates an application interactively. The application name will default to the local folder which is `eb-php`.
@@ -179 +144 @@ This command creates an application named `php-tutorial` and configures your loc
-  2. (Optional) Run **eb init** again to configure a default key pair so that you can use SSH to connect to the EC2 instance running your application.
+For all prompts, except SSH access, accept the defaults to create an environment with the latest PHP platform version. For troubleshooting instances, you can set up SSH access by re-running the `eb init -i`command at a later time, or connect using Amazon EC2 Instance Connect or Session Manager.
@@ -181,6 +146 @@ This command creates an application named `php-tutorial` and configures your loc
-        ~/eb-php$ eb init
-    Do you want to set up SSH for your instances?
-    (y/n): y
-    Select a keypair.
-    1) my-keypair
-    2) [ Create new KeyPair ]
+  2. Create an environment and deploy your application
@@ -188 +148 @@ This command creates an application named `php-tutorial` and configures your loc
-Select a key pair if you have one already, or follow the prompts to create one. If you don't see the prompt or need to change your settings later, run **eb init -i**.
+Run the following command to create an environment named `blue-env`.
@@ -190 +150 @@ Select a key pair if you have one already, or follow the prompts to create one.
-  3. Create an environment and deploy your application to it with **eb create**. Elastic Beanstalk automatically builds a zip file for your application and deploys it to an EC2 instance in the environment. After deploying your application, Elastic Beanstalk starts it on port 5000.
+        eb create blue-env
@@ -192 +152 @@ Select a key pair if you have one already, or follow the prompts to create one.
-        ~/eb-php$ eb create php-env
+When you run the **eb create** command for the first time, Elastic Beanstalk automatically builds a zip file of your application, called a _source bundle_. Next, Elastic Beanstalk creates an environment with one or more Amazon EC2 instances, and then deploys the application into the environment.
@@ -194 +154 @@ Select a key pair if you have one already, or follow the prompts to create one.
-It takes about five minutes for Elastic Beanstalk to create your environment.
+Deploying your application to Elastic Beanstalk might take up to five minutes.
@@ -199 +159 @@ It takes about five minutes for Elastic Beanstalk to create your environment.
-## Step 4: Run your application on Elastic Beanstalk
+## Step 4: Browse your cloud application
@@ -201 +161 @@ It takes about five minutes for Elastic Beanstalk to create your environment.
-When the process to create your environment completes, open your website with **eb open**.
+When the process to create your environment completes, your application should be running and listening for requests on port 5000. Connect to your application with the following command:
@@ -204 +164 @@ When the process to create your environment completes, open your website with **
-    ~/eb-php$ eb open
+    eb open
@@ -206 +166 @@ When the process to create your environment completes, open your website with **
-Congratulations! You've deployed a PHP application with Elastic Beanstalk! This opens a browser window using the domain name created for your application.
+The `eb open` command opens a browser tab to a custom subdomain created for your application.
@@ -208 +168 @@ Congratulations! You've deployed a PHP application with Elastic Beanstalk! This
-## Step 5: Clean up
+## Step 5: Update and redeploy your application
@@ -210 +170 @@ Congratulations! You've deployed a PHP application with Elastic Beanstalk! This
-You can terminate your environment when you finish working with your application. Elastic Beanstalk terminates all AWS resources associated with your environment.
+After you have created an application and deployed to an environment, you can deploy a new version of the application or a different application at any time. Deploying a new application version is faster because it doesn't require provisioning or restarting Amazon EC2 instances.
@@ -212 +172 @@ You can terminate your environment when you finish working with your application
-To terminate your Elastic Beanstalk environment with the EB CLI run the following command.
+Update your PHP code to include the REQUEST_TIME value from the server environment:
@@ -215 +175,2 @@ To terminate your Elastic Beanstalk environment with the EB CLI run the followin
-    ~/eb-php$ eb terminate
+    <?php
+      echo "Hello from a PHP application running in Elastic Beanstalk!";
@@ -217 +178,3 @@ To terminate your Elastic Beanstalk environment with the EB CLI run the followin
-## AWS resources for your application
+      $timestamp = $_SERVER['REQUEST_TIME'];
+      echo '<br/>Request time: ' . date('Y/m/d H:i:s', $timestamp);
+    ?>
@@ -219 +182 @@ To terminate your Elastic Beanstalk environment with the EB CLI run the followin
-You just created a single instance application. It serves as a straightforward sample application with a single EC2 instance, so it doesn't require load balancing or auto scaling. For single instance applications Elastic Beanstalk creates the following AWS resources:
+Redeploy your PHP code to Elastic Beanstalk with the following command:
@@ -221 +183,0 @@ You just created a single instance application. It serves as a straightforward s
-  * **EC2 instance** – An Amazon EC2 virtual machine configured to run web apps on the platform you choose.
@@ -223 +185 @@ You just created a single instance application. It serves as a straightforward s
-Each platform runs a different set of software, configuration files, and scripts to support a specific language version, framework, web container, or combination thereof. Most platforms use either Apache or nginx as a reverse proxy that processes web traffic in front of your web app, forwards requests to it, serves static assets, and generates access and error logs.
+    eb deploy
@@ -225 +187 @@ Each platform runs a different set of software, configuration files, and scripts
-  * **Instance security group** – An Amazon EC2 security group configured to allow incoming traffic on port 80. This resource lets HTTP traffic from the load balancer reach the EC2 instance running your web app. By default, traffic is not allowed on other ports.
+When you run **eb deploy** , the EB CLI bundles up the contents of your project directory and deploys it to your environment.
@@ -227 +189 @@ Each platform runs a different set of software, configuration files, and scripts
-  * **Amazon S3 bucket** – A storage location for your source code, logs, and other artifacts that are created when you use Elastic Beanstalk.
+After the deploy finishes, refresh the page or reconnect to your application with `eb open`. You should see your updates. If not, troubleshoot by running your local server again to verify your changes.
@@ -229 +191 @@ Each platform runs a different set of software, configuration files, and scripts
-  * **Amazon CloudWatch alarms** – Two CloudWatch alarms that monitor the load on the instances in your environment and are triggered if the load is too high or too low. When an alarm is triggered, your Auto Scaling group scales up or down in response.
+###### Congratulations!
@@ -231 +193 @@ Each platform runs a different set of software, configuration files, and scripts
-  * **AWS CloudFormation stack** – Elastic Beanstalk uses AWS CloudFormation to launch the resources in your environment and propagate configuration changes. The resources are defined in a template that you can view in the [AWS CloudFormation console](https://console.aws.amazon.com/cloudformation).
+You've created, deployed, and updated a PHP application with Elastic Beanstalk!
@@ -233 +195 @@ Each platform runs a different set of software, configuration files, and scripts
-  * **Domain name** – A domain name that routes to your web app in the form _`subdomain`.`region`.elasticbeanstalk.com_. 
+## Clean up
@@ -234,0 +197 @@ Each platform runs a different set of software, configuration files, and scripts
+After you finish working with the demo code, you can terminate your environment. Elastic Beanstalk deletes all related AWS resources, such as [Amazon EC2 instances](./using-features.managing.ec2.html), [database instances](./using-features.managing.db.html), [load balancers](./using-features.managing.elb.html), security groups, and [alarms](./using-features.alarms.html#using-features.alarms.title). 
@@ -235,0 +199 @@ Each platform runs a different set of software, configuration files, and scripts
+Removing resources does not delete the Elastic Beanstalk application, so you can create new environments for your application at any time.
@@ -236,0 +201 @@ Each platform runs a different set of software, configuration files, and scripts
+###### To terminate your Elastic Beanstalk environment from the console