Bobcares

How to Set Up Amazon RDS for Laravel

by | Jul 3, 2024

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

How to Set Up Amazon RDS for LaravelAre 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

  1. First, go to the RDS Dashboard.
  2. Then, click on “Create database”.
  3. Next, select a database creation method: “Standard create” for more configuration options or “Easy create” for a simplified process.
  4. Now, select the database engine.
  5. Then, choose the DB instance size as per our needs.
  6. 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.
  7. 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.
  8. Then, review the settings and click “Create database”.

Step 2: Configure Security Group for RDS

  1. First, go to the EC2 Dashboard and select “Security Groups”.
  2. Then, find the security group associated with the RDS instance.
  3. 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

  1. First, select the database instance from the RDS dashboard.
  2. Then, find the “Endpoint” and “Port” details on the instance details page.
  3. Now, log in to the Laravel Forge server.
  4. 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.

  5. 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

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.