This is a sample PHP web application to be run in AWS Elastic Beanstalk.
The intention of the app is to answer a question in stackoverflow.com. The question is how to use mod_rewrite
in AWS Elastic Beanstalk using PHP environment, which uses Apache as web server at the time of writing this app.
Note: This app is NOT secure. Don't use it in actual/production environment. Please destroy the AWS Elastic Beanstalk environment after you tried this app.
The app contains some PHP files:
index.php
: Home pagephpinfo.php
: Printphpinfo()
searchPage.php
: Print$_SERVER
and$_REQUEST
variable
How to create PHP environment on AWS Elastic Beanstalk:
- Open AWS Elastic Beanstalk Web Console.
- Click Create a New Environment.
- Fill the Application Information.
- Choose Create web server and attach appropriate IAM role.
- In Environment Type page:
- Choose Predefined configuration: PHP. Make sure you configuration is 64bit Amazon Linux 2015.03 v1.4.3 running PHP 5.6 or any other compatible configuration.
- Environment type Load balancing, auto scaling.
- Click Next.
- In Application Version page:
- Choose Upload your own and select the zip file of this app (can be downloaded here).
- Choose Fixed and fill the param with 1.
- Click Next.
- Fill the Environment Information.
- In Additional Resources, check on Create this environment inside a VPC.
- Fill the Configuration Details.
- Fill the Environment Tags.
- Fill the VPC Configuration. Make sure your ELB visibility is External.
- Check the Review Information.
- Deploy and wait until finish.
What you can check in this app:
http://<your-env-url>.elasticbeanstalk.com/aws-eb-php-mod-rewrite-sample-master/index.php
: Check for successful PHP deployment.http://<your-env-url>.elasticbeanstalk.com/aws-eb-php-mod-rewrite-sample-master/phpinfo.php
: Check for your PHP environment. You can make sure yourmod_rewrite
is enabled here.http://<your-env-url>.elasticbeanstalk.com/aws-eb-php-mod-rewrite-sample-master/searchPage.php?crs_category=business
: Original PHP script formod_rewrite
test.http://<your-env-url>.elasticbeanstalk.com/aws-eb-php-mod-rewrite-sample-master/category/business/
:mod_rewrite
test. This url will be handled bysearchPage.php
.