Forum Moderators: phranque
I've configured virtual hosts on my apache server for eg - localhost and mywebgallery are the names of my virtual hosts. I'm able to surf to both of them on that computer but if I try to access them from a different computer in my network , only the localhost website comes up.
Is there anyway to configure apache or something in xp that would let me access both the virtual servers in the local network?
Thanks
Rohit
on the hosts file of the server, i have made an entry
127.0.0.1<tab space>localhost mywebgallery
This way I was able to surf and browse both localhost and mywebgallery website on the server only. But when I go to a different computer in the same network, I can't use localhost(as it will try to look into himself) and [mywebgallery...] is not a website.
So I use my internal ip address of the server, but when i do that
[198.169.0.2...] it opens up the website thats hosted under virtual host named "LOCALHOST". So my question is how do i view my other virtual host website through another computer on the same network as the webserver? You talked abt editing the host file on the webserver?
What kind of change will make this work?
thanks
rohit
You talked abt editing the host file on the webserver?
No, actually I said the other machines. For example, if "Bob" has a pc on your network, go to Bob's pc and locate his 'hosts' file. Edit that file to point to your webserver for whatever entry you deem necessary. For example, all the following will point to your internal web server:
198.169.0.2 mywebgallery
198.169.0.2 anothersite
198.169.0.2 yetanothersite
ip address: 192.168.0.3/24
----Hosts file----
127.0.0.1 localhost
192.168.0.3 mywebgallery
192.168.0.3 a2tcp
----Apache - httpd.conf file----
Listen 81
Listen 82
NameVirtualHost localhost:81
NameVirtualHost localhost:82
#My config
<VirtualHost localhost:81>
ServerName a2tcp ---> i have changed the name
DocumentRoot "C:/apache2triad/htdocs"
php_value include_path "C:/apache2triad/htdocs"
</VirtualHost>
<VirtualHost localhost:82>
ServerName mywebgallery
DocumentRoot "g:/WEBROOT/mywebgallery"
php_value include_path "g:/WEBROOT/mywebgallery"
ErrorLog g:/WEBROOT/logs/mywebgallery-error_log
CustomLog g:/WEBROOT/logs/mywebgallery-access_log common
</VirtualHost>
(The reason you see the ports 81 and 82 is because eventually I plan to open these ports on my router so that my parents can visit my website)
Restarted the apache webserver
Now, when I do [a2tcp:81...] -- I see the a2tcp website. Looks promising
when i do [mywebgallery:82...] -- I see my web gallery website....great
Lets go to PC 2....
#############################################################
PC 2 Details (Machine trying to access both the virtual hosts)
ip address: 192.168.0.2/24
----Hosts file----
192.168.0.3mywebgallery
192.168.0.3 a2tcp
Now when i go to [webgallery...] or [a2tcp....nothing...] comes up....thats good because i have assigned port numbers.
Now, when I do [a2tcp:81...] -- I see the a2tcp website. Looks promising
when i do [mywebgallery:82...] -- I again see the a2tcp website....confused the hell out of me......
what wrong am i doing?/
Thanks
rohit
As i mentioned in my previous email I had the following
----Apache - httpd.conf file---- Listen 81
Listen 82
NameVirtualHost localhost:81
NameVirtualHost localhost:82
#My config
<VirtualHost localhost:81>
ServerName a2tcp ---> i have changed the name
DocumentRoot "C:/apache2triad/htdocs"
php_value include_path "C:/apache2triad/htdocs"
</VirtualHost>
<VirtualHost localhost:82>
ServerName mywebgallery
DocumentRoot "g:/WEBROOT/mywebgallery"
php_value include_path "g:/WEBROOT/mywebgallery"
ErrorLog g:/WEBROOT/logs/mywebgallery-error_log
CustomLog g:/WEBROOT/logs/mywebgallery-access_log common
</VirtualHost>
Well instead of using localhost for NameVirtualHost & virtual host directive, they have to be the servernames of the virtualhost. So now my file looks like this
----Apache - httpd.conf file---- Listen 81
Listen 82
NameVirtualHost a2tcp:81 ---> i have changed the name
NameVirtualHost mywebgallery:82 ---> i have changed the name
#My config
<VirtualHost a2tcp:81> ---> i have changed the name
ServerName a2tcp
DocumentRoot "C:/apache2triad/htdocs"
php_value include_path "C:/apache2triad/htdocs"
</VirtualHost>
<VirtualHost mywebgallery:82> ---> i have changed the name
ServerName mywebgallery
DocumentRoot "g:/WEBROOT/mywebgallery"
php_value include_path "g:/WEBROOT/mywebgallery"
ErrorLog g:/WEBROOT/logs/mywebgallery-error_log
CustomLog g:/WEBROOT/logs/mywebgallery-access_log common
</VirtualHost>
This way now from the other computer PC2 I'm able to view both the website using their respective URLs like [a2tcp:81...] and [mywebgallery:82...]
Thanks coopster.
cheers
rohit