Reputation: 864
I am working in a php project using wamp. I have these wamp installed in my public server, so till now when I hit 204.XXX.XX.XX/projectname I could access from any computer inside my university. Now I dont want to display this localhost main screen so I tried virtual host configuration.
C:\Windows\System32\drivers\etc\hosts file
I added
204.XXX.XX.XX api.local #api
httpd-vhosts.conf
<VirtualHost *:80>
ServerName api.local
ServerAlias api.local
DocumentRoot "c:/wamp64/www/api"
<Directory "c:/wamp64/www/api/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I have already enabled the virtual host.
Now from other computer I could not access this api.local project. How can I fix this issue?
Upvotes: 0
Views: 989
Reputation: 94662
THe reason is that the other computer does not know where to find api.local
. The browser will look for that domain name in the DNS Server that is registered to be used on the OTHER PC and obviously not find it.
So the other PC needs to know the ip address to go to when you enter api.local
. You can do this in a number of ways.
If your Uni techs will allow you to add this domain name to their DNS Server this is the best way.
But if they wont allow this, then you will have to edit the HOSTS file on the OTHER PC like this
204.xxx.xxx.xxx api.local
Now this one PC will know where to find your site. However the HOSTS file is normally well protected and you would need Administrator access to change it, which you admins may not allow.
Another way would be to make the site available on a different port, then you can use the WAMPServer PC ip address and a port number to get to your site like this
Listen 8000
<VirtualHost *:8000>
ServerName api.local
ServerAlias api.local
DocumentRoot "c:/wamp64/www/api"
<Directory "c:/wamp64/www/api/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Now use 204.xxx.xxx.xxx:8000
as the site address and you should get to your site
Upvotes: 1