1

I'm using Win7 and all my asp.net applications are running at port 80

I've WAMP installed at c:\wamp and i've my php project folder under c:\wamp\www\ as proj1,proj2 etc.,

Now i tried to create virtual host with below steps

1) edited 'hosts' file and added below

127.0.0.1:9091    testsite1.mymachine.com

2) Opened the file "httpd.conf" at "C:/wamp/bin/apache/Apache2.2.22/conf/" and uncommented the line "Include conf/extra/httpd-vhosts.conf".

3) Opened the file "httpd.vhosts.conf" at "C:/wamp/bin/apache/Apache2.2.22/conf/extra" and added the below

<Directory C:/wamp/www/proj1>
Order Deny,Allow   
Allow from all 
</Directory>

after the above code added the below

<VirtualHost *:9091>   
DocumentRoot "C:/wamp/www/proj1" 
ServerName testsite1.mymachine.com
</VirtualHost>

4) Saved all the above edited files from step 1 through step 3, restarted the wamp server services.

But, i'm unable to access my proj1 using "testsite1.mymachine.com". did i missed anything ? Also please take note by using "http://localhost:8081/" i'm able to see wampserver - server configuration page.

Many Thanks

zneak
  • 134,922
  • 42
  • 253
  • 328
µMax
  • 337
  • 1
  • 6
  • 15
  • Did you make database entry of the URL ? Also i think you can eliminate port from host file. Check this URL: http://foundationphp.com/tutorials/apache_vhosts.php – Reena Parekh Jun 08 '15 at 05:00
  • Do you added Listen 9091 – Suraj Jun 08 '15 at 06:19
  • @Suraj - where to add the listen 9091 – µMax Jun 08 '15 at 06:59
  • if your apache is running on port 8081, then you have to configure your `hosts` and `vhosts` file with the same port, why are you using 9091 port in them? – EhsanT Jun 08 '15 at 07:13
  • Listen 8865 DocumentRoot "C:/wamp/www/proj1" ServerName testsite1.mymachine.com – Suraj Jun 08 '15 at 07:22
  • Here is a post that should explain [how to setup Virtual Hosts](http://stackoverflow.com/questions/23665064/project-links-do-not-work-on-wamp-server/23990618#23990618) – RiggsFolly Jun 08 '15 at 13:33

1 Answers1

1
  1. goto F:\wamp\bin\apache\Apache2.2.21\conf and open httpd.conf file in text editor

  2. change line from #LoadModule vhost_alias_module modules/mod_vhost_alias.so to this LoadModule vhost_alias_module modules/mod_vhost_alias.so (uncomment)

  3. find following lines

    # Virtual hosts #Include conf/extra/httpd-vhosts.conf

    replace it with

    # Virtual hosts Include conf/extra/httpd-vhosts.conf

  4. now goto F:\wamp\bin\apache\Apache2.2.21\conf\extra and open httpd-vhosts.conf at the end add following code to httpd-vhosts.conf

    <VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "C:/wamp/www/(project folder name)"
    ServerName (the name with which you want to deploy your project in the browser)
    ServerAlias (copy paste the ServerName)
    ErrorLog "logs/(deploy_name)-error.log"
    CustomLog "logs/(deploy_name)-access.log" common
      <Directory "/">
         Deny from all
         Allow from 127.0.0.1
      </Directory>
    </VirtualHost>
    
  5. finallly update the hosts file in windows system goto C:\Windows\System32\drivers\etc open hosts using notepad (open notepad as administrator).

    find line 127.0.0.1 localhost

    under it write 127.0.0.1 (copy paste the ServerName from "httpd-vhosts.conf")

  6. restart all the services from wamp.

  7. this should get the virtual host running, just type the server name in the addres bar of browser and hit enter.