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.




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! :)
{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.
BTW, I have a series of posts on setting up multi-instance CF on SSL enabled Apache: http://tinyurl.com/28s6zf
http://eclipservices.sourceforge.net/
You can pick and choose which services to display in an Eclipse tab.
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...
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.
@Scott - Nice Ant script! You Da Man!
I'm using the same setup--Eclipse v3.3 under WinXP.
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)...
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.
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.
That's what makes it easier. :-)
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?
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.
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).
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.
Ant?
Just wondering.
http://www.thecrumb.com/wiki/Ant
@Scott - nice script! I added a link to my wiki.
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!
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. ;)
Your example VirtualHost entry is spot on as well.
If you have a problem, that's one detail that's often overlooked.
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!
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!
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).
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.
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.
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