Tutorials

(not going to finish) Production web serving with Cygwin - PHP, Ruby on Rails & ColdFusion

Tags: 

Note: I'm not going to finish this article as ultimately I ran into problems with Cygwin so migrated to running all Windows-native tasks. Still, in its raw state someone might find some use out of it.

Web development is an interesting field. Many of the technologies you try or wish to use work best with a specific requirement, for example despite attempts to the contrary ASP simply works best on Windows with IIS. Another example of this notion that has become rather common of late is that Ruby on Rails and its related tools really work best on UNIX-like operating systems and doesn't work as well on Windows.

For those "stuck" with Windows for their production web serving there is, however, a work-around called Cygwin, a UNIX compatiblity layer for Windows that has been around since the mid 90's so is very mature and well supported. Cygwin provides the best of both the UNIX world with a robust platform for running many UNIX-only tools, while still providing the Windows foundation which is often needed for e.g. proprietary database drivers. Read on as a give a full list of what you need to install, and how to configure, all of the tools necessary for a pretty comprehensive web development production environment.

Installing Cygwin

The first step is to obtain the Cygwin installer executable from cygwin.com. Run the cygwin.exe program when you download it and you'll see something like the following:
Following through the prompts you'll want to first "Install from Internet" to download all of the required files and install them immediately. On the next screen you'll pick where to install Cygwin, whether to install it for all users or just yourself and whether to make data files use the UNIX or DOS/Windows format - I only ever change the directory path and leave the others at the defaults; the next screen asks where you want to keep the downloaded files, I recommend a sub-directory of where you're installing the main Cygwin system, just to keep them close at hand. The next two screens will ask for your network settings (most people can leave the defaults) and then to pick the Cygwin server to obtain all of the files from - I suggest going through the list and trying some to see how fast they are before picking a favorite.

The next screen is where all the fun is - you get to pick what software to install. I recommend clicking the "View" button to make the list change to a plain list of all of the available software, and maximizing the window, as it can be confusing to work out what category certain apps are in.
Here are the packages we are going to need, besides the basics:

  • apache2
  • gcc
  • gcc-g++
  • gnupg
  • ImageMagick
  • nano
  • curl
  • mhash
  • openssh
  • ruby
  • subversion
  • unzip
  • wget
  • whois
  • make
  • openssl-devel
  • ping
  • bison
  • flex
  • libmcrypt
  • libmcrypt-devel

SSH:
ssh-host-config -y
Give a password
ntsec tty

FreeImage:
make -f Makefile.cygwin
make -f Makefile.cygwin install

PHP
Apache
Ruby on Rails

ruby installed via cygwin
download rubygems
ruby setup.rb
extras:
gem install --remote --include-dependencies rails
gem install --remote --include-dependencies mongrel
gem install --remote --include-dependencies mongrel_cluster
gem install --remote --include-dependencies capistrano
gem install --remote --include-dependencies image_science
gem install --remote --include-dependencies hpricot

GCC
Subversion
FreeImage
ColdFusion
MySQL
SQL Server

http://brantinteractive.com/index.php/?p=47

dmckenna@websrv /home/dmckenna/ruby-dbi
$ mkdir /lib/ruby/site_ruby/1.8/DBD

dmckenna@websrv /home/dmckenna/ruby-dbi
$ mkdir /lib/ruby/site_ruby/1.8/DBD/ADO

dmckenna@websrv /home/dmckenna/ruby-dbi
$ cp lib/dbd/ADO.rb /lib/ruby/site_ruby/1.8/DBD/ADO

http://substantiality.net/articles/2006/10/19/mssqlclient-gem-now-available

SPF the easy way

Tags: 

Sender Policy Framework (SPF) is an open standard that aims to help prevent spam, and stop legitimate email from being tagged as such. While the specifications can take some time to understand, there are some web-based tools to help you make creating your SPF records a little easier than by hand, but I still find them to be a bit misleading. According to the SPF FAQ the simplest way to create your SPF record is to simply list the IP addresses of all servers that mail goes out through, e.g.:

v=spf1 ip4:192.168.0.10 ip4:192.168.0.12 ~all

and just add more "ip4" strings for each address. Then just paste it into a TXT record in your domain's DNS and you're good to go!

Crossover Mac recipe for Outlook 2003

Tags: 

After having problems yesterday getting Crossover Mac to work, today I took a more rigid approach to installing it and it works! Here are the exact steps I took:

  • Create new bottle.
  • Install Crossover HTML components.
  • Install IE6.
  • Started IE and verified that I could view web pages (google).
  • At this point I made a backup of the bottle directory from ~/Library/Application Support/CrossOver/Bottles.
  • Installed Office 2003, selecting only Outlook and customizing some of the installation options.
  • At this point I made another backup of the bottle directory.
  • Started Outlook.
  • Continued through the initial configuration to connect to the Exchange server.
  • Verified that I could open different types of messages, specifically both plain text and HTML.

At this point it was all pretty good now, with some minor issues:

  • It takes several seconds to for a HTML email to display (on a 2x2ghz Mac Pro!).
  • The message list does not refresh properly when a message is removed from the list.

I can live with those two issues, now that I have an apparently fully working install of Outlook, which is what I was after.

So, while I was initially frustrated with Crossover Mac, it does seem to be worth it, if you can spend the time getting your specific software to work correctly.

Catfish fun with script.aculo.us

Tags: 

Script.aculo.us is a wonderful library of Javascript functions for doing lots of buzzword-friendly snazzy effects. A recent schmancy JS trick is the catfish - a small, unintrusive advertisement that pops up at the bottom of the web page and can be closed without affecting the web page. Looking around I didn't see any existing code to do catfish effects with Script.aculo.us so I decided I'd have to fill the gap.

There are four parts to a catfish - the Javascript libraries (Script.aculo.us, which relies upon Prototype), a little bit of HTML structure on your page, some CSS and a single Javascript line. So lets get to it.

To do any of this fancy stuff you need both the Prototype and Script.aculo.us libraries on your site and then load them into the page as follows:

<script src="js/prototype/prototype.js" type="text/javascript"></script>
<script src="js/script.aculo.us/effects.js" type="text/javascript"></script>

Don't forget to change the paths to whatever is correct for your site.

The HTML below needs to be one of the last segments within your HTML, basically it needs to be the last code before the close-BODY tag, so that nothing else throws it off. There's also a link to hide the catfish, you don't want to upset your visitors!

<div id="footer_ad" style="display:none"> <div id="footer_close">[x] <a href="#" onclick="Effect.BlindUp('footer_ad', {duration:1})">close this</a></div>
Catfish is tasty!
</div>

You can put whatever fillings you like in there - nested divs, etc, basically eat your heart out.

The CSS part is pretty straight forward, basically we're setting the div to be locked to the bottom of the web browser window so it slides over the other content - this is a general trick that works great for e.g. shopping cart totals, menus, etc. I used some fairly ugly colors just to make it stand out during testing :-) And for those who don't know, this should either go in your page's CSS file or within a STYLE tag in your page's HEADer.

#footer_ad {
position: fixed;
bottom: 0px;
display: block;
width: 100%;
background-color: #b7948f;
color: #394a8c;
font-size: 24px;
padding: 10px 0 10px 0;
margin: 0;
left: 0;
border-top: 1px solid #9a5261;
}
#footer_close {
float: right;
width; 50px;
display: block;
font-size: 0.6em;
padding: 5px;
text-align: right;
font-size: 0.8em;
}

Last but not least is the Javascript code to make the screen pop up. The best location for this is your body tag's onload attribute, but you could embed it in the page if needed (within a SCRIPT block):

new Effect.BlindDown('footer_ad', {duration:2});

Put that altogether and you too can have some tasty catfish for your site.

There's one last thing, the way the above code works the catfish will keep popping up every time the page is loaded, its left up to an exercise for you on how you'd like to make the close link make the browser remember to hide it. One idea would be to have the onclick event execute a function on the server side to set a session variable that would indicate the visitor no longer wished to see the catfish, then in the presentation code only display the catfish if the visitor doesn't have this variable set; alternatively some Javascript could set a cookie, but I prefer to consolidate all client data in viewer sessions, so there's only one source for all of the relevant data.

Bon appetitè!

Pages

Subscribe to Tutorials