Deploying AcuSensor for PHP - AWS Elastic Beanstalk
AWS Elastic Beanstalk allows you to deploy a web application that can scale to match end-user demand. This simple example will demonstrate how you can deploy AcuSensor together with your web application into AWS Elastic Beanstalk.
Create your Target in Acunetix
For this example, we will assume that the URL for your target is http://eb.acunetixexample.com.
- Create a Target with your URL.
- Enable AcuSensor for the Target.
- Download the AcuSensor agent file acusensor.php and save this file for use later on.
Define the web application source bundle
This simple web application will be defined through the following file structure:
- /.ebextensions/
- /.ebextensions/acusensor.config
- /acusensor/
- /acusensor/acusensor.php
- /public/
- /public/index.php
- /public/test.php
- Create the folders for your source bundle:
mkdir ~/axexample mkdir ~/axexample/.ebextensions mkdir ~/axexample/acusensor mkdir ~/axexample/public |
- Create your ~/axexample/.ebextensions/acusensor.config file to read as follows:
files: "/etc/php.d/acusensor.ini" : mode: "000755" owner: root group: root content: | auto_prepend_file=/var/www/html/acusensor/acusensor.php |
- Create your ~/axexample/public/index.php file to read as follows:
<?php echo "<h1>Test PHP Site Example for AWS Elastic Beanstalk</h1>"; echo "<br>"; echo "Welcome to the main page."; echo "<br>"; echo "<a href='test.php'>Go to the test page.</a>"; ?> |
- Create your ~/axexample/public/test.php file to read as follows:
<?php echo "<h1>Test PHP Site Example for AWS Elastic Beanstalk</h1>"; echo "<br>"; echo "Welcome to the test page."; echo "<br>"; ?> |
- Copy the acusensor.php file into ~/axexample/acusensor/acusensor.php.
- Build the source bundle with:
cd ~/axexample zip -rq axexample.zip . |
Deploy your web application to AWS Elastic Beanstalk
- From your AWS Dashboard, navigate to Elastic Beanstalk > Environments.
- Click Create a new environment.
- Set your environment tier to Web server environment. Then click Select.
- Set the Application name field to the name of your web application. In this example, we used the name axexample-php.
- Set the Platform dropdown to PHP.
- Enable the Upload your code option, then click Choose file.
- Select your source code bundle for upload, then click Configure more options.
- In the Software panel, click Edit.
- On the Modify software page, set the Document root field to /public.
- Scroll down to the bottom of the Modify software page and click Save.
- Scroll down to the bottom of the Configure environment page and click Create environment. AWS Elastic Beanstalk will now create your environment. This can take a few minutes.
- When the process is complete you will be sent to your environment's dashboard. Take note of your environment's new URL which was created automatically by AWS Elastic Beanstalk. You will need this to create a CNAME to point to this URL.
- Create a CNAME for your Target URL to point to your environment's new URL. In our example below we used the Namecheap cPanel interface to create a CNAME for eb.acunetixexample.com to point to axexamplephp-env.eba-uyafmbt5.us-east-1.elasticbeanstalk.com.
- Once the CNAME record has been added (giving time for DNS records to propagate), you can see the web application you have created by browsing to your URL (in this example http://eb.acunetixexample.com).
Test and scan your web application
- Point your browser to your web application (in this example, http://eb.acunetixexample.com) to confirm it is running as intended.
- Run a scan on your Target. The Activity panel will confirm that AcuSensor was detected and used for the scan.