Tools
Deploying PHP Web Applications with Amazon EC2 and Aurora MySQL 📦
2026-01-03
0 views
admin
📘 Introduction ## 🏗️ Architecture Overview ## 🧩 Architecture Components ## 🎯 Why This Project? ## ✨ Key Features ## 🛠️Execution Workflow ## I. EC2 Instance Setup ## II. Amazon Aurora Database Setup ## III. Connect to EC2 Instance ## IV. Install and Configure Apache Web Server ## V. Install PHP and Required Extensions ## VI. Install MySQL Client (MariaDB) ## VII. Configure Database Environment Variables ## VIII. Create PHP Application Files ## 📂 Full Repository ## IX. Restart Web Server ## X. Application Validation ## XI. Resource Cleanup ## ✅ Conclusion ## 🤝 Let’s Connect This project demonstrates the deployment of a PHP-based web application on Amazon EC2 and its integration with an Amazon Aurora (MySQL-compatible) database. The objective is to provision compute and database resources, configure secure connectivity, install a web application stack, and validate database interaction using PHP. The project follows AWS best practices using free-tier eligible resources and focuses on clarity, reproducibility, and proper cleanup. The architecture consists of an Amazon EC2 instance hosting an Apache web server with PHP, connected to an Amazon Aurora MySQL-compatible database cluster within the same VPC. The EC2 instance handles application logic, while Aurora manages persistent data storage. Communication between services is controlled using security groups, ensuring secure and private connectivity. sudo dnf install -y httpd sudo systemctl start httpd sudo systemctl enable httpd sudo dnf install -y php php-mysqlnd sudo systemctl restart httpd sudo systemctl status httpd sudo dnf install -y mariadb105 export USERNAME=admin
export PASSWORD=newadmin12345
export DATABASE=myapp All source code, configuration steps, and documentation are available here: https://github.com/Knandwani07/aws-database-architectures/tree/main/php-ec2-aurora-deployment sudo systemctl restart httpd This project demonstrates a complete workflow for deploying a PHP web application backed by Amazon Aurora. It provides practical experience with AWS compute, managed databases, security configurations, and application-level integration. The structured approach ensures clarity, scalability, and cost awareness, making this project suitable for learning, portfolio use, and interview discussions. For feedback, collaboration, or cloud discussions: LinkedIn: https://www.linkedin.com/in/khushi-nandwani/ GitHub: https://github.com/Knandwani07 Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse - Amazon EC2 Amazon Linux AMI
Apache HTTP Server
PHP application runtime
- Amazon Linux AMI
- Apache HTTP Server
- PHP application runtime
- Amazon Aurora (MySQL Compatible) Managed relational database
Dev/Test configuration
Single writer instance
- Managed relational database
- Dev/Test configuration
- Single writer instance
- Apache HTTP Server Serves PHP web pages
- Serves PHP web pages
- PHP Handles database connectivity and logic
- Handles database connectivity and logic
- MySQL Client (MariaDB) Used to validate database access
- Used to validate database access
- VPC & Security Groups Default VPC
HTTP access enabled
Database access restricted to EC2
- Default VPC
- HTTP access enabled
- Database access restricted to EC2
- Key Pair Secure EC2 authentication
- Secure EC2 authentication - Amazon Linux AMI
- Apache HTTP Server
- PHP application runtime - Managed relational database
- Dev/Test configuration
- Single writer instance - Serves PHP web pages - Handles database connectivity and logic - Used to validate database access - Default VPC
- HTTP access enabled
- Database access restricted to EC2 - Secure EC2 authentication - To understand real-world EC2–RDS integration
- To gain hands-on experience with Amazon Aurora
- To deploy a functional web application stack
- To practice AWS resource lifecycle management
- To build a portfolio-ready cloud project - End-to-end AWS service integration
- Secure database connectivity
- PHP-based application logic
- Free-tier compatible setup
- Structured cleanup to prevent unnecessary costs - Launch an EC2 instance with Amazon Linux AMI - Select a free-tier eligible instance type (t2.micro / t3.micro) - Create and download an RSA key pair (.pem) - Allow HTTP traffic in the security group - Launch and verify the instance - Create an Amazon Aurora (MySQL Compatible) database - Select Dev/Test template - Configure DB cluster identifier and credentials - Use Aurora Standard storage - Select burstable instance class - Don't create aurora read replicas - Connect the database to the existing EC2 instance - Use default subnet group and VPC security group - In additional configuration, give a name to initialize database name - Create the database and wait for provisioning - Open EC2 Dashboard - Select the instance and Click Connect - Choose EC2 Instance Connect - Create a PHP page to establish database connectivity - Create a PHP page to count total page views stored in the database - Access the EC2 public IP in a browser - Confirm page view count increments correctly - Delete DB instance - Delete Aurora database cluster - Terminate EC2 instance - Delete key pair - Verify all resources are removed
how-totutorialguidedev.toailinuxserversubnetmysqlapachedatabasegitgithub