To add a new subdomain to an existing Laravel Forge project, you can follow these steps:
-
Log in to Laravel Forge: Go to the Laravel Forge website and log in to your account.
-
Select the Server: Choose the server where your project is hosted.
-
Add a New Site:
- Click on the "Sites" tab in the server dashboard.
- Click the "Create Site" button.
- In the "Domain" field, enter the new subdomain (e.g.,
site2.abc.com). - Choose the appropriate project type (e.g., "PHP/Laravel").
- Configure any other settings as needed (e.g., web directory, PHP version).
-
Deploy the Site:
- After creating the site, you may need to deploy your code to the new subdomain. This can be done by setting up a deployment script or manually copying the necessary files.
- If you are using a version control system like Git, you can set up a deployment script in the "Deploy Script" section of the new site.
-
Configure DNS:
- Ensure that the DNS settings for your domain (
abc.com) include an A record or CNAME record for the new subdomain (site2.abc.com) pointing to your server's IP address.
- Ensure that the DNS settings for your domain (
-
SSL Certificate (Optional but recommended):
- If you want to secure the new subdomain with HTTPS, you can use Laravel Forge to provision an SSL certificate.
- Go to the "SSL" tab for the new site and click "Obtain Certificate" to get a free Let's Encrypt certificate.
Here is a step-by-step example of how to create a new site in Laravel Forge:
-
Log in to Laravel Forge and select your server.
-
Navigate to the "Sites" tab and click "Create Site".
-
Fill in the details:
-
Domain:
site2.abc.com - Project Type: PHP/Laravel (or whatever is appropriate for your project)
-
Web Directory:
public(if using Laravel) - PHP Version: Select the version you are using
-
Domain:
-
Click "Create Site".
-
Set up deployment:
- If using Git, configure the repository and branch in the "Deploy Script" section.
- Example deploy script:
cd /home/forge/site2.abc.com git pull origin main composer install --no-interaction --prefer-dist --optimize-autoloader php artisan migrate --force -
Configure DNS:
- Add an A record or CNAME record for
site2.abc.compointing to your server's IP address.
- Add an A record or CNAME record for
-
Obtain an SSL Certificate (optional):
- Go to the "SSL" tab for
site2.abc.com. - Click "Obtain Certificate" and follow the prompts to get a Let's Encrypt certificate.
- Go to the "SSL" tab for
By following these steps, you can successfully add a new subdomain to your existing Laravel Forge project.