Learn how to set up Amazon RDS for Laravel. Our Laravel Support team is here to help you with your questions and concerns.
How to Set Up Amazon RDS for Laravel Forge
Are you looking for a way to make your Laravel apps run smoother and faster? Look no further than Amazon RDS.
By teaming it up with Laravel Forge, we can create a reliable and secure database for our projects. Today, our Experts are going to show us how to easily set them up together.
Step 1: Create an RDS Instance
- First, go to the RDS Dashboard.
- Then, click on “Create database”.
- Next, select a database creation method: “Standard create” for more configuration options or “Easy create” for a simplified process.
- Now, select the database engine.
- Then, choose the DB instance size as per our needs.
- At this point, we have to configure the Database settings as seen here:
- DB instance identifier: A unique name for the RDS instance.
- Master username: The admin username for the database.
- Master password: Admin password.
- We can also configure advanced settings as seen here:
- Network & Security: Make sure the RDS instance is in the same VPC and subnet group as the application server. Set appropriate security groups to allow access from the application server.
- Database Options: Set the initial database name if needed.
- Backup: Configure automated backups and retention periods.
- Encryption: Enable encryption if required.
- Then, review the settings and click “Create database”.
Step 2: Configure Security Group for RDS
- First, go to the EC2 Dashboard and select “Security Groups”.
- Then, find the security group associated with the RDS instance.
- Now, edit the inbound rules to allow access from the IP address of the Laravel Forge server or the security group associated with the Forge server.
- Type: Custom TCP Rule.
- Port range: The port the database uses (default for MySQL is 3306, for PostgreSQL is 5432).
- Source: The IP address of the Forge server or the security group.
Step 3: Configure Laravel to Use Amazon RDS
- First, select the database instance from the RDS dashboard.
- Then, find the “Endpoint” and “Port” details on the instance details page.
- Now, log in to the Laravel Forge server.
- Next, edit the .env file of the Laravel application to use the RDS database connection:
DB_CONNECTION=mysql
DB_HOST=RDS_ENDPOINT
DB_PORT=RDS_PORT
DB_DATABASE=DATABASE_NAME
DB_USERNAME=RDS_USERNAME
DB_PASSWORD=RDS_PASSWORD
We have to replace RDS_ENDPOINT, RDS_PORT, DATABASE_NAME, RDS_USERNAME, and RDS_PASSWORD with the values from our RDS instance.
- Now, it is time to make sure the Laravel application can connect to the RDS database. We can run migrations to verify:
php artisan migrate
Benefits of Using RDS with Laravel Forge
- RDS offers several database options and scaling capabilities. It lets us adjust our database resources based on our application’s needs.
- RDS provides robust security features like user authentication, encryption, and automated backups.
- While managed separately, Forge streamlines server management, letting us focus on application development and database configuration within our Laravel code.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
In brief, our Support Experts demonstrated how to set up Amazon RDS for Laravel.
0 Comments