How to set and serve main and sub domain from a single AWS Lightsail instance

Keywords: LAMP/MAMP/WAMP - AWS - How to - Domain Name (DNS)
Description:
I have deployed a Laravel application on AWS LightSail LAMP stack. The app is serving under the main domain e.g. example.com . Now I want move it t app.example.com and use example.com as marketing and company profile purposes. The current codebase is under htdoc directory, not in any subdirectory.

My queries are:

  • How do I achieve the above explained domain structure so that in future i can add more subdomains if necessary?
  • Do I need to make any changes in the DNS records?
  • Is the current SSL certificate issued for exmple.com is usable for future subdomains?

Hi @jhondoedo,

Thanks for using Bitnami. We have a guide on how to install multiple PHP applications on top of your LAMP stack. Can you check it?

https://docs.bitnami.com/aws/infrastructure/lamp/administration/create-custom-application-php/

About the domain, you will need to create a new DNS entry for app.example.com pointing to example.com. It is usually called a CNAME, but it may have a different name on your DNS provider.

For the SSL certificate, you will need to create a new SSL certificate including both domains or two different certificates, one for each site, and configure Apache to use one of them for each virtualhost.

1 Like

Hi Mr. @gongomgra following this guideline able to serve content from app.example.com. but the issue now is i am seeing the same content from sub.myapp.com if accessed from example.com. Do I need some extra configuration anywhere else? Thank you.

Hi @jhondoedo,

We have a Support Tool that will gather relevant information for us to analyze your configuration and logs. Could you please execute it on the machine where the stack is running by following the steps described in the guide below?

Please note that you need to paste the code ID that is shown at the end.

Decryption code generate by support tool:

dcf468aa-66da-ee39-a8ce-1e880d14a051

For example.com there is no .conf file in vhost directory. Could it be the reason according to the below clause from Apache documentation.

The default name-based vhost for an IP and port combination
If no matching ServerName or ServerAlias is found in the set of virtual hosts containing the most specific matching IP address and port combination, then the first listed virtual host that matches that will be used.

Hi @jhondoedo,

I’m afraid I’m not fully understanding your question. Can you give us more details and also the actual domain names so we can check them? We will remove them from your message afterwards.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.