To configure DNS settings for multiple subdomains in Laravel Forge, follow these steps:
Step 1: Create Subdomains
1. Create Subdomains in Laravel Forge:
- Log in to your Laravel Forge account.
- Navigate to the "Sites" section.
- Click on the site you want to configure.
- Click on the "Subdomains" tab.
- Create the subdomains you want to use (e.g., `staging.mysite.com`, `beta.mysite.com`).
Step 2: Configure Nginx
1. Edit Nginx Configuration:
- In the "Nginx" tab, click on the "Edit" button.
- Update the Nginx configuration to include the subdomains:
nginx
server {
listen 80;
server_name staging.mysite.com beta.mysite.com;
root /var/www/laravel_project/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?_share=++;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
Step 3: Configure DNS
1. Create DNS Records:
- In your DNS provider (e.g., AWS Route 53), create A records for each subdomain pointing to the IP address of your server.
Step 4: Test the Setup
1. Test the Setup:
- Visit each subdomain (e.g., `staging.mysite.com`, `beta.mysite.com`) to ensure they are working as expected.
By following these steps, you can configure DNS settings for multiple subdomains in Laravel Forge.
Citations:[1] https://community.cloudflare.com/t/how-should-i-correctly-set-up-dns-for-multiple-subdomains/129560
[2] https://stackoverflow.com/questions/45087924/how-to-configure-subdomain-dns-when-using-laravel-domain-route-on-shared-hosting
[3] https://laravel.io/forum/10-09-2015-two-subdomains-pointing-to-same-location-in-forge
[4] https://www.reddit.com/r/laravel/comments/lg2jqg/anyone_know_how_to_setup_multiple_subdomains_with/?rdt=64313
[5] https://www.youtube.com/watch?v=iIDnoAkXMlE