Monday, May 5, 2014

How to set up Virtualhost using wamp server in windows environment


Assumption


  1. I assume that you have already installed wamp server on your machine
  2. I am using windows 7 64 bit Operating System with wamp 2.2 64 bit version on port 8080
  3. I have installed my wamp server in d:/wamp (Non-Operating system drive on my machine)

Virtualhost settings using wamp server in Windows Environment 

  •  First of Start wamp server from the start menu.















































  •  Now go to the Apache >> Httpd.conf. This will open httpd.conf file in text editor usually in notepad. OR Alternatively you can access this file from file system “D:\wamp\bin\apache\apache2.2.22\conf\httpd.conf”. Go to the wamp folder. Here you will find bin. Now select one of the main components of wamp Apache and go to the apache folder.
  •   Now find out following entries in httpd.conf
        # Virtual hosts
        # Include conf/extra/httpd-vhosts.conf

Initially  Include conf/extra/httpd-vhosts.conf is commented with “#”. You need to uncomment the above entries and it will look like below image.






  • Now create your workspace somewhere else than “D:\wamp\www”. For the example I am creating my workspace in “H:\WorkSpace” and within that directory I am creating multiple project directories such as Project1, Project2…etc.
  • Now you need to set up virtual host configuration by editing httpd-vhosts file. You will get this file on following path “D:\wamp\bin\apache\apache2.2.22\conf\extra\httpd-vhosts.conf”

  • Now setup your httpd-vhost.conf file as displayed in following image.

  • Let’s understand <VirtualHost> tag important parameter properly.

          ServerAdmin:      Mail id of the server administrator on which mail alert should be raised

          DocumentRoot:   This is the physical path of your work space of your project (In our case it  is “H:\WorkSpace\project1”

          ServerName & ServerAlias: Would be how we are going to access our project from web-browser. In simple word access URL

          ErrorLog: To record errors, warning and notices raised during project execution.

  • Once you complete editing save file and close all the unnecessary files. You just one step away from completion.

  • Here is time to add host entries of your project in the system. For this you need to open “hosts” file in administrator mode. You will find the “hosts” file on following location “C:\Windows\System32\drivers\etc\”

  • You just need to right click and open hosts file into Notepad or some text editor and make the entry as below and save your file.

  • By Clicking left click on the wamp icon and select “Restart All Services” from the menu item and wait for wamp server to restart.

  • Now you can access your project by http://local.project1.com



 

No comments: