Awkward feeling

Posted by Bob Silva Thu, 26 Jan 2006 08:30:00 GMT

Ever get that feeling like you just don't fit in? In 1995, I bought my second computer. A Packard Bell Pentium 75 from Sears for $2475 and it came with Windows 3.1 for Workgroups. (My first was a Vic-20 when I was 12 or so, complete with phone cradle modem, cassette tape drive and a subscription to Prodigy Online. When my Dad got the first Prodigy bill, I lost the phone modem. Ever feel a $400 whoopin? I think he even charged interest.)

Back on track.... ever since then, I've stuck with Windows, just because thats what I know. Now that I've entered the Ruby world, I feel like the odd kid on the block, like I have a dirty secret. Watching the mailing list and reading through the tutorials or watching the videos, all you see is Mac OSX. Seems everyone programming in Ruby is doing it on a Mac. I just built a brand-spanking new AMD X2 workstation so I'm not switching anytime soon, or probably ever. But thats not the point, I'm just really curious why Ruby has such a strong following among Mac users. Where's the connection?

The Future of PHP

Posted by Bob Silva Wed, 25 Jan 2006 06:44:00 GMT

I've been programming in PHP exclusively since 1998. It was fun learning the new language and all the power it afforded me over ASP. The first thing I did in PHP was convert a database-backed application written in ASP against SQL Server 6.5. It was a small application, about 1200 lines of code total. By the time I got done with it in PHP, it was less than 500 lines. I was hooked and never looked back.

Last week, talking with an old friend of mine that took my job at my former employer when I left, he introduced me to Ruby and Rails. After only one week, I'm not so sure I see PHP in my future. WOW! is all I can say. How refreshing to actually enjoy programming again. For S&G, I decided to rewrite that same application (which was retired about 7 years ago) in Ruby on the Rails framework. Care to take a gander how many lines this one was? If you guessed under 100, you might have been close. 103 to be exact. Now who can argue with that? To be honest, its not a totally fair comparison. My skillset is leaps and bounds what it was 8 years ago.

I can't totally say good-bye to PHP since I have a TON of legacy code that I don't plan on rewriting, but in the future, the code I write (or don't have to because of Rails) will be in Ruby.

6 short of a dozen

Posted by Bob Silva Wed, 25 Jan 2006 06:37:00 GMT

I bet you're here wondering what my blog title means. Probably not, but I assume if you are here, something caught your attention because it certainly couldn't be my poorly written tutorials. Anyways, the long and short of it is that in 3 weeks, I will be having my 6th child, and YES I know what causes that, obviously I like it a lot. At some point in the future when I have more time to write, I'll reveal more about my family, but for now suffice it to say that I am building my own private empire.

Launching Rails at the Speed of Lite with LiteSpeed Webserver 2

Posted by Bob Silva Sat, 21 Jan 2006 08:39:00 GMT

A walkthrough of how to configure Rails on the LiteSpeed Webserver.

A relatively unknown webserver from LiteSpeed Technologies claims to be six times faster than Apache with a PHP interface that is 50% faster than mod_php. Bold claims, but in my testing, they are not too far from the truth. Lets get started...

T minus 10

Litespeed webserver is available in 3 editions, the standard edition being free (for both personal and commercial use). You can download the latest free version for your platform here. At the time of this writing, 2.1.9 is the current release and there is no windows version (which is a shame because we all know windows needs a fast webserver).

T minus 9

Installing Litespeed is what you would expect for a commercial product.

Extract the tar ball.
# tar xf lsws-2.1.9.tar.gz
Run the installation
# cd lsws-2.1.9
# ./install.sh

This begins the installation process. Take notice that the EULA forbids using it to serve or even affiliate with what they consider to be "illegal" content, even for their paid versions. Interesting concept, nice to see people with the balls to stand up for what they believe, although I don't think the license would hold up in a court of law.

You may want to write down the port you choose to run the administration interface on. I choose 81 because I never write these things down and end up forgetting what I chose.

If you get lost trying to install it then you probably shouldn't attempt the rest of this walkthrough, but if you are a trooper, you can refer to the official documentation.

T minus 8

From this point, I am going to assume you have Ruby and Rails installed already and that you have a Rails project created. If not, you can follow some excellent tutorials here.

T minus 7

Fire up your favorite web browser and login to the LiteSpeed Service Manager. You didn't forget what port you put it on did you? Yea, I thought so, the default port is 7080.

http://mywebserver.com:7080

T minus 6 and counting

All server administration is done through this Service Manager. Click the Server Configuration button on the left and lets get started on the fun part.

  • Create a new virtual host by clicking 'Virtual Host' in the left navbar.
  • This brings up a list of Virtual Hosts. Click Add to add a new one.
  • Give your VH a name. This is an identifer only so call it whatever you want.
  • For the Virtual Host root, make it the root of your Rails project you are going to use for this walkthrough. You'll see why in a minute.
  • In the Config File textbox, enter $VH_ROOT/config/vh_conf.xml. This will store the Virtual Host configuration in your Rails Project config directory.
  • Turn on Follow Symbolic Links
  • Select Yes for Enable Script and Yes for Restrained
  • Save your changes. It may give an error that the config file doesnt exist. Click the CLICK TO CREATE link to create it. Read the warning below first. Now save your changes again. A bit clumsy, but I'm sure they have a reason to do it like that.

I'll leave the rest of the options for you to figure out, none are required to get Rails running. If you need more information on a particular setting, click the Help link in the top banner.

WARNING: Make sure the permissions on your Rails Project config and log directory allow the webserver user write access.
STRONGER WARNING: The service manager has a very short login timeout. Don't be idle for too long without saving or you may lose all your hard work.

T minus 5

Time to buckle in and get ready for to launch. If you successfully saved your Virtual Host, it will be listed in the left navbar under Virtual Hosts. Click on it and lets configure it.

T minus 4

On the General tab, edit the following sections:

General
  • Set Document Root to $VH_ROOT/public
  • For fun, enter your email address so LiteSpeed can send you Cease and Desist letters when your advertising provider let's a porn ad sneak into the mix (yes it does happen and yes you would be violating the EULA).
  • Save your changes
Virtual Host Log
  • Edit the Virtual Host Log section now
  • Choose No on Server Logs
  • Enter $VH_ROOT/log/lsws.log
  • Leave Log Level at Error and set Rolling Size to something like 10M

T minus 3 - We're a GO for launch

On the External Apps tab, click Add and prepare to fire the auxillary boosters:

  • Select Fast CGI App for the type and click Next
  • Give this Fast CGI Instance a unique name
  • For the address, this can be a socket or unix domain socket. We will use a uds here. Enter something like: uds://tmp/lshttpd/myrailsapp.sock
  • Enter something modest for the Max Connections, 20 is good. Make sure you enter the same number in the Instances field
  • Important step: In the Environment setting enter: RAILS_ENV=production
  • Initial Request Timeout => 60
  • Retry Timeout => 0
  • Persistent Connection => NO - Rails will not work if persistent connection is on
  • Auto Start => Yes
  • Heres the big one. $VH_ROOT/public/dispatch.fcgi
  • Backlog => 100
  • Instances - Should match Max Connections
  • Memory Soft Limit => 80M
  • Memory Hard Limit => 100M
  • Process Soft Limit => 200
  • Process Hard Limit => 200

T minus 2 - Fire the boosters

Back on the General tab, you will need to add a Script Handler for fcgi to the External App you just created. In the Suffixes field, enter fcgi, Handler Type to Fast CGI and Handler Name, whatever you just named your Handler. Get ready for liftoff!

T minus 1

Now its time to tell LiteSpeed how to handle Pretty URLs. This is done on the Rewrite tab.

  • Enable Rewrite to on
  • Log Level to 9
Add this to the Rewrite Rules:
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
Save your changes and we are almost there.

Back at the front of the Server Configuration page, select the Default listener under the Listeners on the left navbar. For Virtual Host Mappings, add a mapping to your new Virtual Host by entering the domain name you will use to access it.

The final step will be to apply your changes to the webserver. In the top banner bar, click Apply Changes, then Graceful Restart.

WE HAVE LIFTOFF


Load up your browser again and enter your servers url and off you go! (Assuming again that you have a valid Rails Project)

If everything went as planned, you should be moving at the Speed of Lite on Rails. Otherwise, you may be fish bait, its not pretty when these launches go bad.



This is the first blog entry/tutorial I have ever written so it will be a little rough around the edges. I hope to refine my skills by writing more helpful tutorials. Feel free to tell me if it helped or was totally useless.

Older posts: 1 ... 4 5 6