0

I tried to set virtual host for Magento2(2.2.5) Project in Ubuntu system under Lampp service.

I added this piece of code under opt/lampp/etc/extra/httpd-vhosts.conf

  <VirtualHost *.:80>
  ServerName magento2.local
  DocumentRoot "/opt/lampp/htdocs/Magento2/"
  DirectoryIndex index.php
  <Directory "/opt/lampp/htdocs/Magento2/">
        Options All
        AllowOverride All
        Require all granted
  </Directory>
  </VirtualHost>

And added that under /etc/hosts

127.0.0.1     magento2.local

Uncommented below piece of line under nano /opt/lampp/etc/httpd.conf

Include etc/extra/httpd-vhosts.conf

Restarted the service

/opt/lampp/lampp restart

After this when I try to hit magento2.local it again redirects with the normal URL localhost/Magento2

Nothing works.

Welcome for suggestions.

Thanks in advance.

  • have you change in db? core_config_data table and after that flush cache and check – Kul Sep 7 '18 at 7:01
  • Hi @Kul thanks for the reply.Should I change in core_config_data.Then if I want to keep two virtual hosts for the same project how it will be possible.For example "example1.loc","example2.loc" I want these two domains for the same project.Then in DB how can I mention the two. – anil Sep 7 '18 at 7:37
  • you can only specify 1 url in core_config_data table so not possible to use same db for 2 different url – Kul Sep 7 '18 at 9:38
  • Hi @Kul Then whats the use of virtual host.I'm planning to have two domains for the same project so that it will be useful when I switch the language. – anil Sep 7 '18 at 9:48
  • Okay @anil if you want different domain for language then create store view/store/website and make virtual host that will works for you – Kul Sep 7 '18 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.