localhostvirtual-pc

How do I access localhost ports on a virtual pc?


I've downloaded and installed the Microsoft Virtual PC and Windows XP mode image for testing IE6. I have several projects on localhost that I access by port numbers in my vhosts file, for example:

Listen *:82
<VirtualHost *:82>
    DocumentRoot "path/to/htdocs/project-folder/public/"
</VirtualHost>

In the virtual machine I have changed the hosts file so that http://mymachine redirects to my root localhost directory (equivalent to http://localhost:80/).

How do I set up the virtual machine so that http://project-n/ goes to the correct localhost port? And sadly, http://mymachine:82/ doesn't do the job =(


Solution

  • On the virtual computer, in the hosts file I have added

    xxx.xxx.xxx.xxx      project-n.dev
    

    where the x's are my host computer's ip address.

    In my host computers httpd-vhosts.conf file I changed the *:80 port to localhost:80. I don't know why this works, just that it does.

    My httpd-vhosts.conf file now looks like:

    <VirtualHost localhost:80>
        DocumentRoot "path/to/htdocs/"
    </VirtualHost>
    
    <VirtualHost *:81>
        DocumentRoot path/to/htdocs/project-a/"
    </VirtualHost>
    
    <VirtualHost *:82>
        DocumentRoot path/to/htdocs/project-b/public"
    </VirtualHost>
    

    Now, in the virtual pc, when I goto 'http://project-n:81/' it will load project-a, and'http://project-n:82' loads project-b/public =D