How Do You Set Up Your Development Environment?

We were recently discussing setting up development environments in the #coldfusion channel on DalNet IRC.  This is a discussion that pops up form time to time, so I figured I would share how I set up my development environment.

I use Apache for my development web server, and for each project, I set up a new 'virtual host' so that each project can run form its own web root.  I really have no good explanation for doing this other than its the way I like running my projects.  I give each project a 'serverName' like blog.dev. This just helps me be aware of whether I am on dev or production, and makes it so I have to type less.

Then I set up a new entry in my HOSTS file for blog.dev and point it to 127.0.0.1.

To make editing httpd.conf and HOSTS easier to edit, I set up a project in Eclipse that points to my {apache root}/conf folder.  Inside of that project, I create a linked file to my HOSTS file.  Now from within Eclipse, I can edit my httpd.conf file and my HOSTS file.

I typically will structure my project so that I have a structure that looks similar to:

{projectRoot}
     flex-src (if its a Flex project)
    
support (this is where I put project documents, associated files, artwork, etc)
    
wwwroot this is the web root for my project, and where I point Apache to)

Obviously, as the project dictates, I will add other sub-directories. Also, when using SVN, {projectRoot} will typically be the 'trunk' of the repo.

So, how do you set up your development environment?

UPDATE: Someone asked in the comments for a way to restart Apache from inside Eclipse, well, thanx to Ant, that is very easy.  I attached an Ant file to this entry, you can get it from the 'Download' link below.  Drop this in your {apache root}/conf folder and when you want to restart Apache in Eclipse, right-click the file and choose 'Run As.. --> Ant Build' .  You may need to change the name of the service.  DISCLAIMER: This is offered as is and I make no warranties.  Offer void where prohibited.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Oğuz Demirkapı's Gravatar We have also same structure. I prefer XAMPP which has also PHP & MySQL as default beside Apache.

We are also getting our dev code from SVN. By using ANT we are deploying SVN into our dev/staging/production servers.

Having own root for every project is a must for me. I love it! :)
# Posted By Oğuz Demirkapı | 12/14/07 11:36 AM
Jason Holden's Gravatar I feel compelled to weigh in anytime this topic comes up. I'm using IIS (on XP) for my development. I wrote a small batch file that can quickly switch my current web root to the project I'm working on. Typically I setup my directories like:

{Project}{Trunk}
\subdirectories

When we deploy a project the directory structure typically looks like

{Project}
\www

This allows us to deploy other applications outside the webroot.

I wrote a blog post sometime back explaining my dev setup in greater detail.

This is a good topic because I always find new ways to make my setup more productive.
# Posted By Jason Holden | 12/14/07 11:57 AM
Tom Chiverton's Gravatar The main reason we use that set up, with a virtual host for each project, is that if you develop on http://127.0.0.1/projecta/ but deploy to http://ahost.name/ you *will* screw up sooner or later with the mismatch over web roots.
# Posted By Tom Chiverton | 12/14/07 11:57 AM
Raymond Camden's Gravatar Dude, thank you so much for the idea of using the linked files. Having easy access to those two files is a brilliant idea. Brilliant I say! You are smart beyond measure and handsome to boot.
# Posted By Raymond Camden | 12/14/07 12:19 PM
Cutter's Gravatar I'll mirror Ray's comment, that is an outstanding idea. Now all you need is a batch file to restart Apache services, that you can trigger through Eclipse, and you've got all the bases covered.

BTW, I have a series of posts on setting up multi-instance CF on SSL enabled Apache: http://tinyurl.com/28s6zf
# Posted By Cutter | 12/14/07 2:12 PM
Scott Stroz's Gravatar I am posting this as a comment so anyone subscribing will get the update. I have attached an Ant file that will restart Apache (windows only right now) from inside Eclipse. Details here, http://www.boyzoid.com/blog/index.cfm/2007/12/14/H...
# Posted By Scott Stroz | 12/14/07 3:02 PM
Adrian J. Moreno's Gravatar I've been using this plug-in to manage Windows services from Eclipse.

http://eclipservices.sourceforge.net/

You can pick and choose which services to display in an Eclipse tab.
# Posted By Adrian J. Moreno | 12/14/07 4:03 PM
Dan G. Switzer, II's Gravatar @Scott:

That's a great tip on restarting Apache. I've blogged a solution that shows you how to do the same thing to a remote server (I also changed the example to use IIS just so people can see an example of both web servers.)

http://blog.pengoworks.com/index.cfm/2007/12/14/Us...
# Posted By Dan G. Switzer, II | 12/14/07 4:03 PM
Scott Stroz's Gravatar @Adrian - that plugin is fantastic, thanx!
# Posted By Scott Stroz | 12/14/07 4:14 PM
Dan G. Switzer, II's Gravatar I just tried the plug-in, but it was giving me a cryptic error:

An internal error occurred during: "Configuring Services on 'localhost".
Could not find service idsvcon server localhost

I couldn't connect to any PC local or remote. It definitely looked like an interesting plug-in.
# Posted By Dan G. Switzer, II | 12/14/07 4:20 PM
Cutter's Gravatar @Dan - I just had the same issue. Maybe it's an OS thing? I'm on WinXP with Eclipse 3.3.

@Scott - Nice Ant script! You Da Man!
# Posted By Cutter | 12/14/07 5:21 PM
Dan G. Switzer, II's Gravatar @Cutter:

I'm using the same setup--Eclipse v3.3 under WinXP.
# Posted By Dan G. Switzer, II | 12/14/07 5:30 PM
Rob Wilkerson's Gravatar OS: OS X (Leopard)

My bundled stack of choice: MAMP (the free edition)

Virtual hosts for everything, each configured in a separate include file and stored in a directory named conf.d (to follow the Unix convention). How one develops without having separate web roots for each project is beyond me. I prefer that my dev environment match my production environment as much as possible.

Directory structure:
[projectroot]/_meta (for build scripts, etc.)
/classes
/html (web root)
/logs

Bounce script:
Wrote my own simple, stupid shell script that I access via Cmd+Space (to launch quicksilver), "it" + Enter (to launch iTerm), "restart"+Tab (to engage tab completion that finishes writing "restartmamp.sh" for me), Enter (it's in my path).

I run an internal name server, so I rarely need to mess with my hosts file. Just add a new A or CNAME record and I'm good.

In Svn, I tend to follow the branch-when-needed philosophy. Day-to-day work done on the trunk, development branches created when necessary. Build tags are created each time the project goes out for QA/UAT, release tags each time the project code gets moved to production. A maintenance branch for each version is also created when the code is moved into production.

In Eclipse, I have Mylyn installed which provides me access to my Trac tickets (as tasks) directly within my IDE. It even alerts me - again, in my IDE - when a new ticket is added to one of my projects. A very cool tool if you use Eclipse + Trac.

For anyone that's interested, a bit more at:
http://blog.robwilkerson.org/blog/index.cfm/2007/1...
http://blog.robwilkerson.org/blog/index.cfm/2007/1...
http://blog.robwilkerson.org/blog/index.cfm/2007/3...
http://blog.robwilkerson.org/blog/index.cfm/2007/4...

Whew. Okay, that's about it. Kind of worked up a sweat typing all of that (didn't mean for it to be so lengthy)...
# Posted By Rob Wilkerson | 12/14/07 7:54 PM
Christopher Vigliotti (hibiscusroto)'s Gravatar For bigger projects I like to setup my development environment in VMWare to match the production environment as closely as possible.
# Posted By Christopher Vigliotti (hibiscusroto) | 1/3/08 2:42 PM
Nolan Erck's Gravatar Jumping on the bandwagon...thanks for the post. I have since redone my Dev environment to mirror (most of) your idea. It's making things go much more smoothly!
# Posted By Nolan Erck | 1/11/08 12:55 AM
Trond Ulseth's Gravatar We use IIS for all our servers. All projects have separate locations on the server, and in IIS we use different port numbers for each project. That way each project has its own root, and we don't have to change anything to go from one project to the other.
# Posted By Trond Ulseth | 1/11/08 4:29 AM
Rob Wilkerson's Gravatar @Trond:

That's the part I don't understand. Why separate port numbers to remember? Why not just set up each site on its own virtual host (host header in IIS)? I guess it's personal preference, but using different names rather than port numbers just seems so much easier to me.
# Posted By Rob Wilkerson | 1/11/08 6:21 AM
Tom Chiverton's Gravatar @Rob
Never mind "easier" it more closely reflects your real environment.
You can even fiddle you local 'hosts' file and have the live domain name arrive at your local machines web server.
# Posted By Tom Chiverton | 1/14/08 8:42 AM
Rob Wilkerson's Gravatar @Tom -

That's what makes it easier. :-)
# Posted By Rob Wilkerson | 1/14/08 8:47 AM
Trond Ulseth's Gravatar @Rob & Tom

This way of doing it is not of my design. I simply wanted to tell how we deal with having multiple applications/sites on one IIS dev server.

I'm not a server admin so if you could tell me how you would go about using host headers I'd appreciate it. The way we do now is assign an IP to a site so I access it from my computer by http://devserver:65244. What host header could/would I add, and what would the url be?
# Posted By Trond Ulseth | 1/14/08 9:30 AM
Rob Wilkerson's Gravatar @Trond:

Your server has an IP and IIS listens on that IP (port 80, by default). Just set up multiple sites in IIS and then set host headers for each so that the sites (sometimes called virtual sites or virtual hosts) answer to a different name even though they exist on the same IP. This solution really just uses host names to do what you're using port numbers to do.

I don't have an IIS server in front of me or I'd try to be even more prescriptive. Hope that helps, though.
# Posted By Rob Wilkerson | 1/14/08 9:50 AM
Trond Ulseth's Gravatar So if I understand right http://devserver would open one site, and http://app1 would open another?

Still on our network we would then have to somehow set that http://app1 should point to the devserver (I am really blank when it comes to configuring networks and servers), so I'm not sure how we'd do that. Some of my colleagues knows this, but I'm guess it's not easier than just asigning a port number when creating a new site in IIS.

Also we have a subdomain pointing to our internal dev server, like http://devserver.ourcompany.com - and whenever we want to discuss some aspect of the project we point our client to http://devserver.ourcompany.com:65244" target="_blank">http://devserver.ourcompany.com:65244 (or whatever portnumber we use for that project.) This would also not be that easy using host headers I assume (please correct me if I'm wrong).
# Posted By Trond Ulseth | 1/14/08 10:56 AM
Rob Wilkerson's Gravatar "So if I understand right http://devserver would open one site, and http://app1 would open another?"

If I understand you correctly, then you're almost right. You have a dev server (devserver) that currently supports multiple sites (for example, app1, app2, app3...appN). You would configure your hosts file (or an internal DNS server) to point the names app1, app2 and app3 to the IP of that dev server. That dev server's IIS config, then, would have separate sites configured - each answering to its own name and all on port 80.

"This would also not be that easy using host headers I assume (please correct me if I'm wrong)."

Nope, even that's pretty easy. You could configure another site (named, say, devserver) on the dev box and then ask your sys admins who are in charge of your corporate DNS servers to create what's called an A record on those servers. That record might look something like this:

devserver IN A [IP of your dev server]

Now, whenever a request is sent through the DNS servers that own ourcompany.com that server essentially forwards the request to your dev server which knows how to handle the request because you just configured a site for it. This is probably already done since your devserver seems to already respond to those requests - albeit on a separate port number.

It sounds more complex than it is. Promise. The first step is to simply start using names instead of port numbers to identify inbound requests.

Hope this helps.
# Posted By Rob Wilkerson | 1/14/08 11:54 AM
Craig Hyatt's Gravatar For those of you who use separate dirs for src and web root, how do you quickly deploy from src to web root when you want to test a code change?

Ant?

Just wondering.
# Posted By Craig Hyatt | 1/31/08 3:10 PM
Jim Priest's Gravatar Ant = deploy anywhere :)

http://www.thecrumb.com/wiki/Ant

@Scott - nice script! I added a link to my wiki.
# Posted By Jim Priest | 1/31/08 6:21 PM
jyoseph's Gravatar When you say "Then I set up a new entry in my HOSTS file for blog.dev and point it to 127.0.0.1"

Would it be too much trouble to ask for an example entry in each of the files (conf file and host file).
I'm trying to set up a local development environment in the same way as your example illustrates. I'm so close but still no cigar. I have MAMP, CF8 and the lovely Eclipse installed (OSX 10.5).

You make mention of the files and I've fiddled with them but haven't ever been able to get it working fully. Thanks!
# Posted By jyoseph | 2/1/08 6:36 PM
Raymond Camden's Gravatar Um, for HOSTS, there isn't more you can say. All HOSTS entries are is an address and an IP. That's it. Nothing more. Take a look at your own HOSTS file and you will see. So for that at least, Zoid really can't say more cuz there isn't more. :)
# Posted By Raymond Camden | 2/2/08 12:49 PM
jyoseph's Gravatar awh, c'mon Ray, GIVE ME ALL THE ANSWERS! :-)

No I do understand what you mean though. I was just confused as to how you can add multiple entries. For instance:

127.0.0.1   dev.test1.loc
127.0.0.1   dev.test2.loc

That going to be ok? And then I need a new virtual host entry for each of those sites in my appache http.conf file?

[VirtualHost *:80]
ServerName dev.test1.loc
DocumentRoot "/Users/MyComputerName/Sites/test1"
[/VirtualHost]

Throw me a bone here I'm a newb. ;)
# Posted By jyoseph | 2/2/08 1:23 PM
Scott Stroz's Gravatar That is it exactly. Just like with DNS, you can have as many entries pointing to a single IP (and in this cae its 127.0.0.1) as you need/want.

Your example VirtualHost entry is spot on as well.
# Posted By Scott Stroz | 2/2/08 1:55 PM
Rob Wilkerson's Gravatar It's worth noting that the server:port value in your virtual host block ([VirtualHost *:80]> must _exactly_ match the value of your NameVirtualHost directive. In my experience, the default value is typically "*:80", but I have run into a few installs where that is not the case.

If you have a problem, that's one detail that's often overlooked.
# Posted By Rob Wilkerson | 2/2/08 2:41 PM
jyoseph's Gravatar Awesome, thanks guys for the reassurance. I'll check into the port issue as well. I think 80 is correct as I have MAMP set to 80 also.

I have other semi-unrelated questions that deal with mapping but am going to read through the links above that direct to http://blog.robwilkerson.org to see if they're covered there.

Thanks again!
# Posted By jyoseph | 2/2/08 10:30 PM
Steve Lionbird's Gravatar @Rob - I'm looking to set up a similar development environment but I'm shaky on the DNS details. Here's what's set up and what I'd like to do:

We have three development servers here each for different types of projects. I would like it so that each dev server be given it's own name (e.g. dev1, dev2 ..) so that each can simply be accessed (from inside our network) like so - http://dev1/

I've made changes to my local hosts file to accomplish this, the only problem is that I don't want to have to make updates to EVERYONE's local files each time a dev server is changed up or added etc.

So the key is centralization. How exactly can I set up our local DNS server to accomplish the same thing as the hosts file without screwing any "real" dns stuff up. Can I use the above one-word names or do I need to use fully qualified domain names?

Btw this is such an elegant and production-friendly method when used with virtual hosts: car_site.dev1, fruit_site.dev2, vegetable_site.dev2, beastiality_site.dev3, etc. I can't wait to get it working :D

Thanks for you help!
# Posted By Steve Lionbird | 7/24/08 5:22 PM
Jim Priest's Gravatar Do you currently have a DNS server in-house? Setting up a DNS isn't too bad depending on your network environment.

Another low-tech option - put your hosts file in SVN. Have everyone checkout a working copy. When you update the file - everyone simply does an update (you could easily automate that so it happens once a day).
# Posted By Jim Priest | 7/24/08 9:57 PM
Rob Wilkerson's Gravatar @Steve

Jim's low tech idea will work beautifully. I use the same technique to keep my entire team's Svn config file up to date. That said, configuring DNS for this is pretty easy. I actually gave the answer above. If you have 3 servers, you would configure:

dev1 IN A xxx.xxx.xxx.xxx
dev2 IN A xxx.xxx.xxx.xxx
dev3 IN A xxx.xxx.xxx.xxx

Similarly, if those IPs already have an existing name, you could use CNAMEs:

dev1 IN CNAME existingname
...

As Jim hinted, the key is to a) have an internal DNS server, and b) have access to edit the zone file (or the server's hosts file if you're using dnsmasque). Hopefully this helps.
# Posted By Rob Wilkerson | 7/24/08 10:12 PM
Rob Wilkerson's Gravatar I should add that the settings above are useless if your workstations aren't configured to look at this DNS server first. If they are, then you should be able to access them as http://dev[1-3]. To get the further granularity you mentioned, you can use CNAMEs:

carsite.dev1 IN CNAME dev1
...

Make sense? You might want to avoid underscores in your domain names. Those can do some funky things with cookies.
# Posted By Rob Wilkerson | 7/24/08 10:15 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9. original design by tri-star web design