Magento 2 - Setup Multiple Websites/Stores on localhost

Keywords: Magento - Installers - How to - Domain Name (DNS)

Description:
I currently have my Magento Bitnami stack on an internal ip 192.168.15.159. I have used the below command and I can access Magento storefront and admin perfectly fine.

sudo /opt/bitnami/configure_app_domain --domain 192.168.15.159

I want to add more websites in Magento and am wondering if I can do so just using an ip address. It seems that configurations with multiple websites call for a DNS address such as “mysite.mg”

I have tried configuring the app domain to “mysite.mg” and have added mysite.mg pointing to the static ip in the VM’s hosts file but when I try to access Magneto through a web browser is times out and references a failure to redirect from “redirect.aaaq.com” When I ping “mysite.mg” it does return “192.168.15.159”.

I’d appreciate greatly it if you could point me in the right direction.

*Update

So I’ve been able to add more websites and access them using subdomains. With the Bitnami stack domain still configured at 192.168.15.159, I’ve added websites/stores/store views in Magento :

website1.mysite.mg – store code “website1”
website2.mysite.mg – store code “website2”

I’ve included entries in the host file of the host and guest OS:

192.168.15.159 website1.mysite.mg
192.168.15.159 website2.mysite.mg

The below article talks about adding code to the .htaccess file

https://docs.bitnami.com/installer/apps/magento/configuration/enable-multisite/

It seems somewhat contradictory because the next article mentions adding the “SetEnvIf Host “ code to the .conf files in the Apache dir rather than the .htaccess file. Perhaps 1 article is a little bit older than the other.

https://docs.bitnami.com/aws/apps/magento/administration/use-htaccess/

I’ve added the “SetEnvIf Host” entries using the method’s described in the second link (Approach A).

All 3 sites load up fine.
192.168.15.159 – Default Site – store code “base”
website1.mysite.mg – website1 – store code “website1”
website2.mysite.mg – website2 – store code “website2”

Since I have all this working perfectly, I would like the Default site to be “mysite.mg” as well.

When I try to change the domain to “mysite.mg” using the below command, add entries in the host file, and add the “SetEnvIf Host” host code in the “/opt/bitnami/apache2/conf/vhosts/htaccess/Magento-htaccess.conf” file and restart Apache, I can see the top and bottom frame of the website load then I type “mysite.mg” in a browser, but it does not load. It times out. I have cleared cookies/site data.

sudo /opt/bitnami/configure_app_domain --domain mysite.mg

So it looks like the problem is just now with the main “base” Magento website. When I switch everything back to “192.168.15.159” it all works as described above. I should also note that the sub-domains still work when I change the configuration to “mysite.mg” Only the base website and admin page is not accessible.

Any help would be appreciated.

Hi @isaacabides,

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?

How to Run the Bitnami Support Tool in a cloud image or virtual machine

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

Regards,
Michiel

Hi Michiel,

I installed and ran the Bitnami Support Tool. The ID code is : 6ded6e7d-fbdd-eca7-eaad-c08672a3658d

Thanks

Hi @isaacabides,

Can you try to configure the domain in the /etc/hosts file on your machine instead of the VM. Could you try that?

Regards,
Michiel