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.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF