0

When using Virtual Host, where should I point my browser to?

I'm trying to set up Virtual Host for Example.com. My understanding is that if all good, I have to point the browser to Example.com/phptest.php in order to access page phptest.php. But it's not working. On the other hand, if I point the browser to localhost/phptest.php, it is returning the phptest.php page.

The pertaining directory/files structure is as below.

ls -l /var/www/html/example.com/public_html
total 12
-rw-r--r-- 1 ubuntu ubuntu 203 Nov 25 14:49 index.html
-rw-r--r-- 1 ubuntu ubuntu  21 Nov 25 18:56 info2.php
-rw-r--r-- 1 ubuntu ubuntu 641 Nov 25 13:48 phptest.php

Any help will be appreciated.

BlueSkies
  • 2,145

1 Answers1

1

Adding 127.0.0.1 example.com in /etc/hosts file solves the problem.

The browser should be pointing to http://example.com/phptest.php.

Note: Make sure that the server-name variable in the php script accessing MySQL (phptest.php in our case) is set to "example.com".

BlueSkies
  • 2,145