How to host 2 different sites on WAMP server and access them both via the internet?

1

I can only access my website from another PC if I use the PC/WAMP server hosting the website IP in the url address.

This becomes inconvenient since I need to host two different website using the same IP address. Which is not possible. You cannot create another virtual host and use the same IP in the address.

How can same be done?

WhiteRose

Posted 2019-09-02T09:56:36.627

Reputation: 23

1

It's called virtual host.

– Michal Przybylowicz – 2019-09-02T10:02:42.070

Answers

0

You cannot create another virtual host and use the same IP in the address.

You cannot use the same IP without some method of differentiation between sites. The simple way to get around this is tell Apache to Listen on other ports (usually in httpd.conf, but not always) and set up your virtual hosts accordingly.

ex. virtual hosts file

# Enables e.g. 1.2.3.4 (a.k.a 1.2.3.4:80) and 1.2.3.4:1234

# Listen 80 should already be enabled
Listen 1234

<VirtualHost *:80>

# ServerName host1.example.com
# ServerAlias some.example.com

DocumentRoot "C:/path/to/site1/"

</VirtualHost>


<VirtualHost *:1234>

# ServerName host2.example.com
# ServerAlias another.example.com

DocumentRoot "C:/path/to/site2/"

</VirtualHost>

Of course, the drawback to this is that you will need to specify the port for your second site.

I can only access my website from another PC if I use the IP of the PC/WAMP server hosting the website.

You may want to check out a dynamic DNS service that provides subdomain names such as NOIP. Alternately, if you want a completely free domain name, you can try a .tk domain.

Anaksunaman

Posted 2019-09-02T09:56:36.627

Reputation: 9 278