Matthew Woodward // * CFML, Grails, and Java Developer
* Principal IT Specialist, US Senate
* Open BlueDragon Steering Committee Member
* All-Around Geek
Contact Loren Scherbak (contact info below) if interested.
========================================sudo apt-get install apache2INSTALL MYSQL
sudo apt-get install mysql-server mysql-clientINSTALL VIM & EMACS
sudo apt-get install vim emacsYou can also install Java and Tomcat via apt-get, but I prefer to download these items directly from their respective sources. We'll start with Java.DOWNLOAD/INSTALL JAVA
PATH=${PATH}:/opt/java/jdk1.6.0_22/bin
export PATH
JAVA_HOME=/opt/java/jdk1.6.0_22
export JAVA_HOME
Save the file, and then you'll have to log out of your terminal and log back in for these settings to take effect. Type exit and then hit enter to close your terminal, and then re-open the terminal. To make sure your settings took, type the following in your terminal, hitting enter after each line:echo $PATH echo $JAVA_HOMEYou should see the Java directory included in your path, as well as see it for the value of JAVA_HOME.Note that by editing .bashrc the changes only affect your user. If you want these settings available to all users, you'll be editing /etc/profile instead. DOWNLOAD/INSTALL TOMCAT
cd ~/tomcat/bin vi setenv.shWhat we'll be adding to this file is some settings that Tomcat will use when it starts up. Depending on your machine and/or preferences you may want to adjust the memory settings, but if you aren't sure what this stuff does, these are decent generic settings and you can always change them later. Add these two lines to setenv.sh and then save the file:
export JAVA_HOME=/opt/java/jdk1.6.0_22 export CATALINA_OPTS="-Xms512m -Xmx1024m -XX:MaxPermSize=384m"Again if you know what you're doing here, feel free to change your memory settings accordingly. You should now be able to fire up Tomcat without any errors, so navigate to ~/tomcat/bin in your terminal and type ./startup.shYou'll see a few lines spit out to the terminal, and if you don't see errors, open up a browser and go to http://localhost:8080 If you see the Tomcat welcome screen you're good to go. Note that I won't be covering additional Tomcat configuration here, particularly hooking it into Apache, because there are a ton of other howtos and blog posts about that very topic. If you have specific questions in this area I'm happy to help, so comment below and I'll either comment or write another blog post as necessary. ADDITIONAL CONFIGURATION
yourusername soft nofile 10000 yourusername hard nofile 10000DOWNLOAD AND INSTALL SPRINGSOURCE TOOL SUITE/ECLIPSE
cd ~/Downloads tar -xvf NAME_OF_FILE_HERE.tar.gz mv NAME_OF_EXTRACTED_DIRECTORY_HERE ../STS has a bit of a different directory structure since it comes with tcServer and Roo, so you'll actually go into the directory and be moving the STS directory into your home directory. Since it has a long name like springsource-tool-suite-sts-2.3.2-RELEASE or something like that, I tend to move and rename to something shorter, e.g.:
mv LONG_DIRECTORY_NAME_HERE ~/stsOnce things are moved, you can go into the directory that you moved to your home directory (which will be either sts or eclipse most likely), and then type either ./STS or ./eclipse to launch the program. ADD LAUNCHER FOR STS/ECLIPSE
Thanks to the attendees for participating in what I hope was a useful and informative session. Whether or not you were at BFusion, feel free to email me with any questions you have about anything related to free/open source CFML.
A few quick tips if you find yourself having to access a network drive from Apache and Tomcat on a Windows Server. This is all pretty much old hat but since I still get questions about this fairly regularly and was just setting up some things on some servers this weekend, I figured I'd write this up.
In my situation we're running an application on three VMs behind a load balancer, and users can upload files from the application. Since I didn't want to set up a process behind the scenes that copied uploaded files between all three servers (though it would have given me a chance to take another run at using Unison), we have an uploads directory living on a SAN. This way no matter which VM the user is on, the uploads all go to and are served from a single file system.
On Windows Server, by default services run under the Local System Account, which doesn't have access to network resources. So if you install Apache and Tomcat as services and expect to be able to point them to a UNC path for some of your content, that won't work out of the box. You need to be running Apache and Tomcat under an account that has network access. In most environments in which I've worked this type of account is typically called a "service account," because you'll end up getting a domain account just like your typical Active Directory user account, but of course it won't be associated with a human being.
Once you have that account in place, you go into your services panel, right click on the service, click on "Properties," and then click the "Log On" tab. You'll see by default the Local System Account radio button will be checked. Click the radio button next to "This Account," enter your service account information, click "OK," and then restart the service. At this point your service will be running under the service account and will have access to network resources. Note that you'll have to do this for each service that needs access to the network drive, which in my case meant doing this for both Apache and Tomcat.
That takes care of the web server and things at the Tomcat level in terms of basic access, but you'll likely be configuring an alias of some sort to point to the network drive. In my case I wanted /uploads to point to \\server\sharename\uploads, which meant setting up an alias in Apache, a Context in Tomcat, and a mapping in OpenBD. This is where a lot of people get confused, so I'll go through each of these settings one by one.
The necessity for a web server alias is probably pretty obvious. If you're serving an image directly from your web server, e.g. http://server/uploads/image.gif, if /uploads doesn't exist under your virtual host's docroot, then Apache will throw a 404.
Allowing Apache to access the network drive involves (depending on how you have Apache configured) using a Directory directive to give Apache permission to access the directory, and then an Alias directive so Apache knows where to go when someone requests something under /uploads. So the following goes in your virtual host configuration file:
<Directory "\\server\sharename\uploads"> Order allow,deny Allow from all </Directory> Alias /uploads "\\server\sharename\uploads"
You may have other stuff in your Directory directive as well but that's the basics of what will allow Apache to see /uploads as the appropriate location on your SAN.
The next layer down will be your CFML engine. Remember that if in your CFML code you want to read or write files to /uploads, even though Apache knows what that is now, your CFML engine will not. I'm emphasizing that point because it's such a common source of confusion for people. If things are happening in your CFML code, it won't be interacting with Apache at all, so it won't know about the Alias you set up in Apache. Simple enough to solve with a mapping; just go into your CFML engine's admin console and create a mapping that points /uploads to \\server\sharename\uploads and that handles things at the CFML level.
Lastly comes Tomcat. Depending on how you're serving files, you may be proxying from Apache to Tomcat, so if Tomcat needs to know where /uploads lives, since it's not in the webapp's base directory Tomcat will throw a 404 unless you tell it where /uploads is located.
Tomcat doesn't have Aliases in the same way Apache does, but what you can do in Tomcat is configure multiple Contexts under a single host. So in Tomcat's server.xml (or in a separate host config file if you prefer), you simply add a Context that points /uploads to the network location:
<Host name="myapp"> <Context path="" docBase="C:/location/of/my/app" /> <Context path="/uploads" docBase="\\server\sharename\uploads" /> </Host>
So now you have things set up in such a way that Apache, your CFML engine, and Tomcat all know where /uploads really lives.
Another point of confusion for people on Windows is the concept of "mapped drive" letters. A lot of people think that if you map \\server\sharename to a drive letter of let's say D:, than in your code you can then access the uploads directory we've been using as our example via D:\uploads.
The simplest way to explain why this doesn't work is to point out that mapped drive letters are associated with a Windows user account. They don't exist at the operating system level. While you may remote into the server using your credentials, map to a network location, and assign that to drive letter D:, another user logging in won't see that mapping, and services running on the server under various user accounts definitely won't know anything about mapped drives.
This is why in all the examples above you see the full UNC path to the network resource being used. You have to use the UNC path in order to get this all to work correctly because that's the only way services running under a service account will be able to address the network resource.
Hope this helps eliminate some of the persistent confusion I see around this issue.
BFusion/BFlex is coming up on September 11 and 12, 2010 in lovely Bloomington, IN. You need to be there, and here's why.
I've been invovled with BFlex/BFusion since the first year and it's one of my favorite conferences. I'm particularly excited this year to be able to help people delve into the open source CFML engines, so I hope to see lots of you there.
Great training, great price, great location, and great people. What are you waiting for? GO REGISTER NOW!
As a corollary to Sean's post about running Railo, OpenBD, and ColdFusion on JRun, I thought I'd outline my preferred development environment these days, which is to run all the necessary CFML engines on Apache Tomcat. Note that this approach will work equally well on Jetty, JBoss, GlassFish, or more or less any servlet container or JEE server you choose.
Great minds think alike because coincidentally enough, Dave Shuck also has just published two blog posts (part 1, part 2) about setting up a similar environment. I figure I'll throw mine out there as well because the more information available the better.So why not use JRun? Well, aside from the fact that JRun is getting very long in the tooth at this point, personally (and you'll probably hear me say this in a couple of conference presentations this year), I think the ColdFusion model stands Java on its head a bit, particularly when you do a standalone install of ColdFusion. Yes, it makes it easy to install and configure ColdFusion, but in my opinion it also shields people from how Java web applications actually work, so I've become a big fan of treating ColdFusion like what it is: a Java web application.This to me makes far more sense than letting ColdFusion and JRun dictate your Java environment. And I think you'll see in this blog post that "installing" CFML engines on Tomcat is actually easier than installing ColdFusion. The only even remotely tricky part is installing Tomcat (and in most cases it isn't tricky at all), so let's tackle that first.As an aside, if you just want to try Open BlueDragon and don't want to bother with the Tomcat installation, just download the Ready2Run Jetty + OpenBD distribution, start Jetty, and you're done!Installing Tomcat
As with OpenBD above, just put your CFML files in /path/to/tomcat/webapps/railo to run them on Railo in the railo context path.
Installing ColdFusionColdFusion is a bit of a different beast since Adobe doesn't distribute a standard WAR file, but luckily you easily can generate one by running the installer. The steps below are when you run the installer on Linux but the same principles apply on other operating systems. Let's generate a WAR file for ColdFusion.At the end of this process you have a CF 8 WAR file sitting in your install directory (which by default on Linux is /opt/coldfusion8). Now the installation is more or less as above with OpenBD and Railo since we have a standard WAR file we can deploy on Tomcat:
Great Post and looking forward for your future post on this topic.
@Sean--concerning the webroot outside the Tomcat area, do you mean having your CFML files in a directory elsewhere on your hard drive? Like /home/user/mywebs as opposed to being in the Tomcat webapps directory?
It seems like I heard that Adobe wasn't going to support JRun any more, am I remembering wrong?
@Jake--they announced some time ago that they will not be developing new features for JRun.
The last official update was in 2007.
ColdFusion/JRun FAQ is here:
Personally it seems to me they'd do better forgetting about JRun and shipping ColdFusion as a standard EAR/WAR distribution, but I understand that they have an investment in the JRun + CF combo so that probably won't happen, at least for a while.
@sean Part of what Matt is talking about here having a more standard JEE configuration. Having a war access resources outside of itself seems to go against the spirit of what Matt is talking about accomplishing. You can configure tomcat itself to look for war files anywhere on the system by adding a context element to server.xml (Confluence standalone does this very nicely refer to it as a good example). Maybe later I'll post my ANT file for people if they want to use it to deploy to the different war's (which is how I have my dev setup). I have a builder attached to each Eclipse project which deploys the code to all configured war files.
@Adam--yep, that's part of it too. I'm becoming a massive fan of just dropping a WAR with everything in it on a production server when I need to deploy an app, not to mention it keeps my development environment dang tidy.
I understand the value of a packaged WAR but for development at least, it's nice to have a single webroot for a project with all your CFML engines pointing to the same place.
I believe you can configure Tomcat to serve specific directories for specific hostnames and then you could use a symlink from webapps/something to the actual webroot?
Great timing, a few week's ago I tried to do the same but with Apache in the mix. I think I'll take another look.
Looking forward to that next post. Could you comment here to alert us when it's up maybe?
Thanks.
@sean I still don't like the approach personally but hey we all have our quarks. Anyone interested in doing it this way is probably looking for is allowLinking. You would specify this in a context element in the server.xml (due to windows security issues this is disabled by default). More info:
@Adam @Matt Based on your comments then, you advocate holding all files for a web application under the context root in Tomcat (ie /usr/tomcat/webapps/projectX)?
Maybe I'm missing something but doesn't that force all requests to go to the app server, instead of just the CF-related requests. That seems to be counter-productive to me in that we want Apache to serve graphics, css, html and other "non-CF" stuff because that's what it's good at.
I'd like to move to having all my CF engines active under Tomcat (and in fact as of right now have CFMX7, CF8, OpenBD, and Railo3 deployed to Tomcat on my Mac). My issue is that I keep projects sorted by client under my home directory as in /Users/userName/Sites/ClientName/ProjectName so that multiple projects for a specific client stay together. Then I can create Apache vhosts to point to the correct folder for that project
I really want to find out how to replicate the proxy behavior that the JRun connector gave us that only sent .cfm, .cfc etc to the app server while letting Apache do what it excels at.
Looking foward to your next posts. Hopefully it'll come later this week so that I can play with some of this configuration while I'm on the RIAdventure cruise next week!
Counterproductive because ... ? You can set things up a bunch of different ways, but I think the notion of "use Apache for static content because it will be faster" is antiquated at this point (and it's a notion I held until I read more about the various Tomcat connectors). Using the native Tomcat HTTP connector is actually going to perform better than using the AJP connector, which would hand CFML processing off to Tomcat while Apache would handle everything else.
So what I'm saying is unless you really *need* Apache (and you may ...) you can use the HTTP connector built into Tomcat and get far better performance for both dynamic and static content, and the setup is a lot more straight-forward.
On my VPS right now I'm using Apache and just proxying out to Tomcat + OpenBD for all my CFML content. I did it this way because I already had Apache configured, and I do have a couple of sites running on here that are straight HTML, but I'm going to convert these over because proxying is actually the least performant option. As fast as things run even using proxying I can't wait to see how fast things run on Tomcat with the native HTTP connector. :-)
Apache is no better at fielding requests than the Tomcat HTTP connector (like Matt was saying). What apache excels at, over tomcat's HTTP handling, is configuration (and this is based off older experiences this too may have changed). Unless you have a configuration that can not be done easily in Tomcat I'd just use Tomcat (or jetty for that matter). Even if I do need an http server I use lighttpd or ngineX over apache these days. The only reason apache is installed on my personal server is for SVN (which last time I checked the connector was still in early works for lighttpd).
At work it is a different story we have a dedicated logical partition (actually multiple clustered HTTP servers) that handle some of our static content and proxy to a cluster of CF servers. Again though we do this not for performance but because we use siteminder and it has to connect to either IIS or Apache (or a derivative). Since we have that http server we figured why not put all of the reusable static content on a shared partition and host it straight off there, while anything that is app specific remains packaged in the war.
@Matt - How do you deal with URL rewriting without Apache?
One interesting point I'd like to discuss regarding proxying requests in this type of setup. I run an NginX / HAProxy combo as my proxy layer. Much smoother then apache for static content and the likes.. But I find that when proxying a request for "/" to "/cfusion" or what have you, theres an anomoly w/ the cookies wherein each cookie seems to be tied to not only a domain, but also a context root. Have you had an experience with this happening?
@Adrian--depends on how much URL rewriting you need. You can easily set up hosts on Tomcat just as you do on Apache to have Tomcat respond to normal URLs without the port and context path and point those to a specific web app.
You can also do more full-blown URL rewriting on Tomcat, either directly or through an add-on. I haven't tried it myself but Tomcat does include a URLRewriteFilter that lets you put rewrite rules in place.
I'll know a lot more once I cut the Apache cord and run pure Tomcat. ;-)
I receive a HTTP Status 404 - /cfusion/
Any ideas?
NM, I had to put in the full url: http://localhost:8080/cfusion/CFIDE/administrator/index.cfm Duh!
Always useful to know this stuff, but would be even more useful if it wasn't anti-windows, as that is after all what most of us use, it is only a small minority of developers who use Linux and even most CF hosts also use windows.
@Russ--not sure how not poking fun at windows makes the information itself more useful. I'm a firm believer in the free software movement so I don't use Windows unless I'm forced to, and just because from some people's perspective "most people use Windows" that doesn't mean I'm required to take my time to cater to Windows users when I myself hardly use it at all. It's not my main area of familiarity. Not to mention the fact that with legions of Windows users out there, someone else can surely take anything I post that's Linux specific (which this isn't!) and modify it for Windows.
And frankly I don't think Linux/Mac users are as small of a minority as you may think they are, and many people are interested in learning about Linux, so I think I'm filling a need there.
Also, I think people need to have a sense of humor about the whole thing. So I hate Windows--so what? All this stuff is Java anyway, so even my Windows-specific post about getting all this stuff running is only about 10% Windows-specific. If people get something out of my posts and also lose a bit of the fear of the unknown when it comes to Linux in the process, all the better as far as I'm concerned.
Matt,
I am sorry you hate windows that much that is causes you to rant like a rabid dog in to a harmless comment, which is simply a statement of fact. Perhaps you need to take a chill pill there and stop getting so angry, it is just an operating system, and it is the one most of the population uses whether you like it or not.
@Russ--first off, I'm not ranting like a rabid dog, so I'm not sure where you're coming from when you make a comment like that. I realize you can't hear my tone when just reading text, but I honestly don't think I'm the one who needs the chill pill here. 99% of my bitching about Windows is intended to be humorous--why are you getting so angry and defenseive about me not liking Windows?
Second, not that this even needs to be said, but it's my blog and if you don't the way I present things, you're certainly free to get your information elsewhere.
Lastly, as I said in my other comment (and frankly it sounds like a lot of this is coming out of you being frustrated about something wholly unrelated to my attitude about Windows ...) I don't use Windows much, and given the fact that I don't like Windows I'm certainly not going to spend my time installing and using Windows to cater to people who do use it. Majority doesn't rule here--I have a choice not to use Windows and I choose not to. Everyone's free to make their own choice.
Again, I'm really not angry. Seriously. So I'm not sure where your vitriol is coming from. If it's just an operating system why do you care so much that I don't like it? Do you expect me to suppress my attitude on my own blog so I don't "offend" Windows users? I just don't get it.
I'm afraid you have lost me now Matt, I am not angry or defensive, nor have I said anything angry or defensive. The only anger I can see here is yours i'm afraid. I personally don't care whether you like windows or not, it certainly desn't affect my life in any way. All I said was it would be better if it was not so anti-windows, which is simply my opinion, i'm afraid I cannot fathom why this has sent you off in such a rage.
Can someone post a WAR for Adobe's CF so that we don't have to go through the install process...
@Baz--that would be against the terms of the CF license I believe. It's really not *that* bad and once you have the WAR file created, you can re-use it so you don't have to create it every time.
@Matt What pain in the license :) My Ubuntu desktop is so nice and clean, I'm hesitant to have some installer litter it...
I'm sure it wouldn't be a big deal. anyone can download the trial/developer edition and generate a war file, so you are not giving anything away as it would still be a trial/developer ediiton without a license.
I know in the past it has been an issue--I know at least a couple of people who asked Adobe if they could provide the CF runtime with sample apps and the answer was an unequivocal no. Maybe that's changed.
Hi. I appreciate your article on setting up openbd but I am having an issue that likely has a simple fix. Being a newbie I simply cannot figure it out and was hoping you could help. I would like to put my site in a sub-directory of my "/etc/tomcat/webapps/openbd" directory. But as soon as I change my tomcat host from "/opt/tomcat/webapps/openbd/" to "/opt/tomcat/webapps/openbd/mysite/", it no longer works. I get a "HTTP Status 404" error. ANY help with thiw would be HUGELY appreciated.
Has anyone figured out to configure railo and coldfusion to use the same webroot on a windows machine?
I can specify a webroot in the railo administrator but i can't tell how to do this for coldfusion. If you are interested in details, take a look here: http://serverfault.com/questions/47109/coldfusion-8-does-not-accept-document-...
this may be a dumb? but you recommended using the java 1.6 update 10, on osx, it runs the java update through the os updater and i noticed that it is not version 1.6. I am currently on 10.5.8 and its running:
java version "1.5.0_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-b02-304)
Java HotSpot(TM) Client VM (build 1.5.0_19-137, mixed mode, sharing)
will this cause an issue or is there a way around this to update it to the latest version? I am hesitant to affect anything that can screw up my machine.
Thank you Matt
@Chris--I haven't heard of any problems with Java 1.6 on the Mac, but of course you can simply point Tomcat to Java 6 if you don't want to make it the default before Apple officially ordains it as the default. (As an aside, Apple handles Java very strangely IMO.)
So, if you've done all the OS X updates as far as I know you'd have Java 6. So you can point Tomcat directly to that and you should be in good shape. Note that the latest nightly of OpenBD REQUIRES Java 6, as will (presumably) versions moving forward, so you'll at least need to point Tomcat to Java 6 in order to be able to run OpenBD.
Let me know if you need more details.
@Matt from what I have found out, you can either switch the java preference in the java utilities app or going through ADC to get the coming updater: http://adcdownload.apple.com/Java/java_for_mac_os_x_10.5_update_5_developer_p...
I changed my pref and when I use java version in terminal I am now showing "java version "1.6.0_13"
@Eric--sorry, was going back through old emails and couldn't remember if I ever addressed your question.
Some common problems that might cause what you're seeing are A) you're not restarting Tomcat after you make a configuration chnage; B) you don't have your site files and your WEB-INF files in the same place; or C) your config file syntax isn't correct.
If you're still having trouble feel free to email me and I'll help if I can.
Yes, the lack of "official support" for Tomcat is odd since JBoss 4.0.3, 4.0.5 and 4.2 are all officially supported!
I've never had much luck getting Tomcat to work with a webroot outside of its install tree - could you post instructions for that?
I guess my ideal setup would be to use Apache vhosts to select which engine handles the code but to have each project have its own webroot that all three engines can see, e.g.,
dev-cf.project.com -> CF8 and {workspace}/project/wwwroot
dev-railo.project.com -> Railo and {workspace}/project/wwwroot
dev-openbd.project.com -> OpenBD and {workspace}/project/wwwroot