If you’re a web developer, you may need to work in both .NET and PHP. If you do not have multiple computers for your development environments you will likely run into issues if you’re not setup correctly. Since I develop in C# and PHP mostly, I needed a way to develop locally with Windows and Apache web servers. My development computer currently runs Windows 8 as the operating system, so I needed to sit down and get to work.
Do not be afraid, there is a way to accomplish such a feat and I’ll help guide you through the process that has helped me multiple times with different Windows computers. The first step is making sure that you have IIS installed and setup, so that is where we’ll begin.
If you already have setup your computer in a similar way, or have already reached a point, use the navigation on the right to jump to the section that you’re interested in or that you want to continue from.
If you have any questions feel free to contact me at email@example.com. Be sure to include something in the subject that references this post so I can make sure I see the email and reply as quickly as possible. You could also leave a comment below as the development community is always one to help others with issues.
If you haven’t done so already, you will need to install IIS. This is a fairly simple task since Windows provides a way to install IIS. You must first open up the “Programs and Features” dialog, and you can find that by either going to the Control Panel, or typing in appwiz.cpl into the run dialog, which can be opened by pressing the Windows Key + R. You will need to click the “Turn Windows Features on or off” link on the sidebar.
Once the Windows Features dialog fully loads, you will want to check the “Internet Information Services” checkbox. By default it should check everything you need for hosting a website, but, since we’re developers here you may wish to explore the checkboxes and see what features you need. For me, since it’s just my personal development space, I like to check everything.
Once you have finished checking the features you would like, clicking the OK button will show a dialog of the changes being applied.
There you have it! Microsoft Internet Information Services (IIS) is now installed and fully operational. That is only one of the steps to getting you up and running with IIS and Apache. Next up, we will install and configure Apache to work alongside IIS.
For my machine, I setup and use WAMPServer for my PHP programming. WAMPServer can be downloaded here: http://www.wampserver.com/en/#download-wrapper. You will want to click the “you can download it directly.” link to be redirected to the download on SourceForge. Once you download the copy of WAMPServer that you wish to use, we can begin the installation process.
You will want to go through the several dialog prompts throughout the installation process. When you get to the “Select Destination Location” prompt, the best place I’ve found is the default location which will be C:\wamp.
The next step will allow you to create a desktop and or a quick launch icon. After that you will see the installation screen and process. Once that is complete, you will be able to setup your mail options.
You can either set these up with your details or you can just leave them blank.
After the mail parameter setup, you will have successfully installed WAMP.
Usually you would access WAMPServer by navigating your browser to localhost, unfortunately that will not work. Go ahead and give it a try if you don’t believe me. You should get something similar to the below image.
What’s this?! Why is IIS showing up on my localhost? IIS always listens to traffic on localhost port 80, and since we installed IIS earlier, any access to localhost will result in us seeing the IIS screen. In order to resolve this, we need to configure WAMPServer to listen to traffic on a different port number.
We can do this by clicking the shiny new WAMPServer icon in your system tray. WAMPServer gives you a quick and easy way to open up the file you will need to modify. Open up the httpd.conf file and look for the line that says “Listen 80”. You need to change that number to something else like “888” or “8080”.
After that has been done, you will be able to access WAMPServer by visiting localhost:8080 in your browser. Since I setup my httpd.conf file to Listen 8080, I would use 8080 as my port number, however, if you set it up as a different number, be sure to use that as your port number.
Now you’re all set to work on both .NET and PHP websites within your local development environment! That didn’t take too long, so you should have plenty of time to spend on all of your fantastic ideas and projects!
You can leave off here, however, if you’d like to make it a bit easier with working in PHP, keep reading for another configuration that will allow you to set up virtual hosts.
It takes a little bit of work to get virtual hosts to work on Windows, but in my opinion it is worth it. To begin you’ll need to edit your hosts file which can be found here: C:\windows\system32\drivers\etc\. Following the default style in there now, enter your localhost IP (127.0.0.1) and then the url you’d like to access your development site by, new-project.dev for instance. Once you’ve entered in all the virtual hosts you’d like, make sure to save the file.
It is important to note that for each new virtual host you wish to setup, you will need to modify the hosts file.
The next thing you need to modify is back in the httpd.conf file, which again can be opened directly from the WAMPServer icon in the system tray, the steps for that can be found above in Step 4 of the Installing and Configuring Apache section. Search for the lines:
You want to remove the octave or hash before that include statement.
We then need to go to the file that is included with the line we just uncommented. That can be found at C:\wamp\bin\apache\apache[VERSION #]\conf\extra\, and we want to edit the httpd-vhosts.conf file.
We want to give Apache permission to look into our main projects directory. At the bottom of the file, add the following:
<Directory C:/wamp/www> Order Deny, Allow Allow from all <Directory>
<VirtualHost new-project.dev:8080> DocumentRoot “C:\wamp\www\new-project” ServerName new-project.dev </VirtualHost>
Your httpd-vhosts.conf file should now look like the following:
It’s important to note, that we must add the port number into the Virtual Host designation. We also will need to modify this file for each new virtual host we wish to setup.
The DocumentRoot is the path to where the site files are located, and the ServerName should match the domain we entered into the hosts file earlier.
The DocumentRoot must be inside the directory that we previously gave Apache permission to view.
In order for all of these changes to take effect, we must restart our Apache services. We can look back to Installing and Configuring WAMPServer Step 5 for how to restart. A quicker way is to just restart all of the services together. Click the WAMPServer icon and then the “Restart All Services” and wait for the WAMPServer icon to be green again.
I know this was a long read, however, having all of this information in one place rather than scattered over several blogs would have helped me greatly. So with that in mind, I hope you enjoyed this tutorial and found it as beneficial as I have. Thanks for reading!