How to setup a WAMP working environment
Most of you probably work on multiple projects, at the same time, with multiple workspaces defined in your IDE, with different Apache server configurations on each of them. That’s a lot of variables, isn’t it? What about unifying things? What about getting all together? In the last years, I’ve managed to work with several server configurations, but most of them focused on Apache (both v1 and v2). Experience tells me that separating server from your workspace is the best way to do:
- your projects should not be in the server’s folder
- all projects should be in one folder, a workspace
- both projects and workspace should not be near the OS (I’m thinking about Windows here)
So, either you work on Windows, OS X, or Linux, either you use XAMP, WAMP or MAMP, or pure httpd/apache, your system&server configuration can be used for multiple projects. Bellow I’ve sketched a step-by-step guide on how to rapidly configure a Win box for this purpose. The guide can be ported to both OS X & Linux machines, with the appropriate software. Here we go:
- download WampServer
- install wampserver in a E:\server folder
- sort & get your projects into a E:\workspace folder
- open E:\server\bin\Apache2.2.11\conf\httpd.conf
- enable mod_rewrite.so by removing the hash sign
- enable conf/extra/httpd-vhosts.conf by removing the hash sign
- now, for each domain.tld you should:
- open C:\windows\system32\drivers\etc\hosts
- add the following line
1127.0.0.1 domain.tld - open E:\server\bin\Apache2.2.11\conf\extra\httpd-vhosts.conf
- replace the old NameVirtualHost by commenting the directive, and add a new record for each domain
1
2#NameVirtualHost *:80
NameVirtualHost domain.tld- add following for the localhost
1
2
3
4
5
6
7
8
9
10
11
12<VirtualHost localhost>
ServerAdmin webmaster@localhost
DocumentRoot "E:/server/www"
DirectoryIndex index.php
<Directory "E:/server/www">
AllowOverride All
Allow from All
</Directory>
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>- add vhost settings for your domain.tld, and for each other domains, as much as you want
1
2
3
4
5
6
7
8
9
10
11
12<VirtualHost domain.tld>
ServerAdmin webmaster@domain.tld
DocumentRoot "E:/workspace/domain.tld"
DirectoryIndex index.php
<Directory "E:/workspace/domain.tld">
AllowOverride All
Allow from All
</Directory>
ServerName domain.tld
ErrorLog "logs/domain.tld-error.log"
CustomLog "logs/domain.tld-access.log" common
</VirtualHost>
- open C:\windows\system32\drivers\etc\hosts
Now you can happily drink a beer and enjoy!