WAMP or its equivalent on other systems provides an ideal setup for hosting Drupal websites locally; however, to serve local files correctly a Virtual Host must also be configured correctly.
Virtual hosts allow you to run multiple domain names on one Apache server while managing them independently – this feature is especially helpful in isolating development from production environments.
Installation
WAMP (WAMP Server A, MySQL, and PHP) is an Apache, MySQL, and PHP stack for servers running Windows or Linux operating systems. Mac versions can sometimes be found as well, though these are less prevalent. When first installing it presents you with additional information relating to Virtual Hosting which describes how WAMP associates files with URLs that it can serve – though this step isn’t essential in setting up WAMP it can still provide valuable knowledge of what to expect during its usage.
Once WAMP has been installed, you can launch it from the system tray icon. At first it may look red; when all services have started running it will change to green and you can visit localhost to visit your website, as you configured WAMP with virtual hosting.
Virtual hosting enables you to serve multiple websites from one web server, making this feature particularly helpful when working with multiple developers on one project. A virtual host also enables you to set up directories similar to those found on production servers; such as setting aside a subdirectory of “/www” as your development folder.
To set up a virtual host in WAMP, it will require editing both the Windows hosts file and WAMP virtual host file. To edit this latter one, go to C:WindowsSystem32driversetchosts (it should only be edited by users with administrator privileges), using Notepad in admin mode to make edits before saving and restarting WAMP after saving changes made to file(s).
Configuration
WAMP provides you with the option to configure a virtual host (Vhost) with either a named domain or IP address, with IP being recommended when working with version control utilities to avoid conflicts between sites on your development machine. To establish one, edit both Windows hosts file and the WAMP Server vhost file before creating virtual hosts.
The Windows hosts file is located in C:WindowsSystem32driversetchosts and contains hosts.txt by default; however, you may alter its extension as desired to any type of file extension. After editing the hosts.txt file, restart your computer for your changes to take effect.
After restarting your computer, click the WAMP icon in the task bar and choose Restart All Services to relaunch WAMP Server and access virtual hosts created. To test that your Virtual Hosts are functioning properly, visit your browser and type one of them; if your website loads, your Virtual Host should have been configured properly; alternatively you could use phpMyAdmin’s New Database feature and create one there before being asked for username/password login details before creating new databases – either way should work!
Deployment
WAMP (WordPress, Apache, MySQL and PHP) server packages allow web application development on your local Windows system. Having access to version control utilities helps manage multiple versions of one website at the same time; however, using one directory like “Wampwww” to store all development files can be restricting if working on multiple projects at the same time with various code editors – virtual hosts provide an effective solution.
Virtual hosts (vhosts) enable one web server to serve multiple distinct websites with separate configuration settings and content, each having their own specific IP addresses and physical network interfaces. This is accomplished by segregating them using either multiple physical network interfaces on one machine, multiple virtual network interfaces on one physical interface or by assigning different IP addresses for each website within that vhost.
No matter which virtual host method is chosen, creating one requires creating a directory on your disk for each project and setting up WAMP server to access these directories. You must also modify Windows hosts file so the web server knows which path it should follow when opening local files on the system.
To create a virtual host with WAMP desktop, launch it, right click localhost, select Tools in the right-side menu, select ‘Add Virtual Host” and follow through until the page for configuring virtual hosts is shown.
Assuring you’re editing the correct hosts file is as easy as opening it with an editor with administrator privileges and changing both hostname and documentroot to reflect your project name and directory respectively. Once finished editing the hosts file, save and close it before restarting WAMP server from its system tray icon and visiting localhost again to view your new locally hosted website.
Troubleshooting
WAMPServer allows you to quickly create virtual hosts to serve multiple local websites from a single machine, making this perfect for testing purposes as well as saving you from managing multiple ports in your browser. However, initial usage can sometimes present issues; when this occurs troubleshooting steps may help quickly and effectively solve these issues.
To create a virtual host in WAMPServer, launch Notepad or another text editor with administrative rights and edit the file hosts at C:WindowsSystem32driversetchosts; change its file type from All Files (.) and make sure that it can be read readable before restarting WAMPServer and accessing its name from a web browser.
Once completed, close the information screen that appeared. WAMPServer will now link your local files with URLs it can serve. Although this method of hosting can be very convenient and secure at the same time.
Remove PHP extensions that you don’t require for your project in order to improve server performance and prevent server bloat. If you are not using MySQL, disable it as otherwise you may experience slow performance and lag when developing. Taking these steps will ensure a functional development environment as well as keep WAMPserver running smoothly.


