Setting up WAMP Server can be tricky depending on your configuration. This post is going to walk you through some of the tougher steps to get your local machine up and running so you can get back to development.
Keep in mind this is not a newbies guide to WAMP. Look elsewhere if you can’t get the basics working. What we are trying to tackle here are more advanced problems that you may experience.
A couple of snags I hit were WAMP running slowly, APC refusing to install, and getting cURL working.
At the time of writing this, the current bleeding edge WAMP Bundle has the following specs:
Apache 2.4.2 – Mysql 5.5.24 – PHP 5.4.3 XDebug 2.1.2 XDC 1.5 PhpMyadmin 188.8.131.52 SQLBuddy 1.3.3 webGrind 1.0
In my particular case, I opted to run 64bit code but I do not see any benefits other than making things more difficult. You may want to stick with 32bit.
Installing WAMP at the start is easy and I am going to assume you can handle clicking next on the install screen and get the basics working. Since you are using Windows 7/8 it is important that you install the latest runtimes for your setup:
http://www.microsoft.com/download/en/details.aspx?id=8328 x86 (32-bit)
http://www.microsoft.com/download/en/details.aspx?id=13523 x64 (64-bit)
It is also extremely important to make sure IIS is not running on your computer. To do that go to: “Turn Windows Feature On and Off” and disable IIS, otherwise it will take up Port 80 and waste resources.
After a few reboots you should be at the point where you can configure PHP/Apache and add additional extensions.
This is where the fun begins. To get to the Apache configuration file Left Click on WAMP Server systray and browse to Apache -> httpd.conf. I am not going to go through the entire process, but will add some useful code snippets.
If you have any subdomains then this is the time to set those up and it looks something like this:
As you can see, I have two separate projects FantasySP and Top IAmA, one running on localhost and the other on rlocalhost. Most of you will have your DocumentRoot as \www\ and can probably skip this bit. (Also, don’t forget to update your Windows HOSTS file.)
One of the snags you may encounter at this point might be getting Apache to recognize .htaccess files. I modified my rules to look like this:
Allow from all
Another snag might be the fact you can’t access the server at all. By default it may “Order Deny,Allow”, then specify a specific IP that has access. You can either update your localhost IP or just use “Allow from all”.
By default Apache has a few modules disabled that should be enabled. Left Click on WAMP Server systray and browse to Apache -> Apache Modules. You will want to enable deflate_module and rewrite_module. Without the rewrite module your clean URLs won’t load. Without deflate enabling gzip compression will cause a configuration error. If you have expires rules in your htaccess file then include the expires_module.
If Apache is still having errors then chances are you need another missing module or you screwed up your httpd.conf file. Make sure you back this up before you start fiddling around.
Now that Apache is up to snuff, it’s time to add missing PHP extensions and configurations.
Immediately you may want to enable the PHP short open tag. Left Click LAMP Systray -> PHP -> PHP Settings. Otherwise things like <? and ?> will cause errors.
(However, as septor in the comments pointed out, the short open tags will affect XML documents.)
Next up is making sure the cURL is working (assuming you want this). In my case, cURL would not work with the included extension so I had to find an updated version that would work on my PC.
Grab the latest cURL extension that fits your OS. Overwrite php_curl.dll in your WAMP folder similar to this: C:\wamp\bin\php\php5.4.3\ext
Restart Apache and run <? phpinfo(); ?> to see if cURL shows up this time. If it doesn’t then try a different DLL file until it does show up.
The biggest pain in the ass will be to get APC working. After a bit of frustration I finally figured out the easiest way to get it working.
In your php.ini file add the following line at the end to first DISABLE APC. apc.enabled=0. It is important APC is disabled first because it will make debugging a lot easier.
Find the correct php_apc.dll file that will work for your setup. You can find that on this handy page full of modules.
You can either try each one and restart apache if you’re lazy. Or you can look at your phpinfo output to see what version you need. TS stands for thread safe. VC9 stands for the runtime library it was compiled with. (Remember when you installed those runtimes a bit earlier?).
Copy the .dll into the ext folder and restart apache. If you picked the wrong one then Apache will crash. Otherwise the systray icon will turn Green. Once it appears in phpinfo output then you’ve found the right one.
Go back to your php.ini configuration and change apc.enabled=1. There is a good chance Apache will crash once APC is enabled. I think this has to do with the fact Serialization Support shows as Disabled (or broken). That value should show up as “php”.
After dealing with this problem for a day or so I read that you had to copy the php_apc.dll file into one of your Windows System folders.
If you are running 64bit WAMP then copy php_apc.dll into C:\Windows\SysWOW64. For 32bit copy into C:\Windows\System32.
Only do that last step if Apache errors when APC is enabled. I have no idea why these files need to be copied there, so if you know the reason then feel free to post in the comments.
At this point you can specify your own advanced APC configurations if you want.
Fixing Slow Performance
Right after I started testing FantasySP on localhost I quickly realized that it was much slower under this configuration than my last configuration.
Last time I was running PHP 5.3 with Apache 2.2.x. So either the new Apache was slow or PHP.
As of this writing WAMP comes with Apache 2.4.2. The latest version right now is Apache 2.4.4. Apparently Apache 2.4.4 uses VC10 runtimes instead of VC9 to enhance performance under Windows.
I figured it might be best to update Apache to see if that would improve the speeds. I got the latest Apache Build and created a new directory in wamp/bin/apache/apache2.4.4.
I coped over wampserver.conf from the apache2.4.2 directory and my httpd config file. I also re-enabled my PHP extensions. You can now specify which version of Apache you would like by Left Clicking the WAMP systray -> Apache -> Version.
Once WAMP Restarted using the newer version of Apache it was much faster. Though there was still something slowing it down.
I watched task manager in Windows 8 to see which applications were using a lot of CPU. (A great reason to upgrade to Windows 7+ is the improved task manager). Anyways, I noticed that Windows Defender was using a lot of CPU when httpd.exe or mysqld.exe would run.
As it turns out, real-time spyware protection was slowing things down! Open up Windows Defender (or whatever you use for spyware/virus protection) and exclude real-time protection for httpd.exe and mysqld.exe.
It also makes sense to disable Windows Indexer from indexing C:/Wamp/*.
Phew. After all of those configurations and changes, localhost runs as fast as my previous setup under Apache 2.2 and PHP 5.3. As long as you take the time to set things up properly then things should run smooth under Windows 7 or Windows 8.
Even though you will experience growing pains by updating your WAMP environment I highly suggest taking a weekend to do so to make sure your applications run well on an updated stack.
Hopefully this post has proved useful to easing your pain during the WAMP setup process. I have a strong feeling that I will be consulting this very blog post 3 years down the road when I have to do it all over again…