Gemstone/S and FastCGI with lighttpd
I was reading the post from James Foster about configuring Apache/FastCGI for serving Seaside. I prefer Lighttpd because, as its name implies, it needs less resources to run. And with virtual hosting, as I have my servers, memory it is a big factor.
I followed the steps to install Gemstone/S in my machine. Instead of a hosted server, I used my laptop with my user as server.
After testing that Seaside was running OK in my machine, using:
miguel@laptop:~$ source /opt/gemstone/product/seaside/defSeaside
miguel@laptop:~$ startGemstone
miguel@laptop:~$ startSeaside_Hyper 8080
and navigating to:
http://localhost:8080/seaside
I stoped the Hyper Webserver with Ctrl+C.
Now to install lighttpd in my Debian GNU/Linux 4.0 etch machine. As root:
laptop:~# aptitude install lighttpd lighttpd-doc
and backup the default config file:
laptop:~# cp /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.bak
then use this configuration for lighttpd.conf:
# Modules activated
server.modules = ( “mod_access”, “mod_alias”, “mod_accesslog”, “mod_fastcgi” )
# Document root, maybe there you have other sites also
server.document-root = “/var/www/”
# logs
server.errorlog = “/var/log/lighttpd/error.log”
accesslog.filename = “/var/log/lighttpd/access.log”
# Welcome file
index-file.names = ( “index.html” )
# Do not server files beginning with
url.access-deny = ( “~”, “.inc” )
# Server config
server.port = 80
server.pid-file = “/var/run/lighttpd.pid”
dir-listing.encoding = “utf-8″
server.dir-listing = “disable”
server.username = “www-data”
server.groupname = “www-data”
# FastCGI
# Debug enabled, disable on production sites
fastcgi.debug = 1
# Do FastCGI for anything with prefix /seaside
# load-balancing with 3 hosts
# check-local disable searching the requested file in the lighttpd document root and
# forward the request to the fastcgi hosts
fastcgi.server = ( “/seaside” => (
( “host” => “127.0.0.1″, “port” => 9001, “check-local” => “disable”),
( “host” => “127.0.0.1″, “port” => 9002, “check-local” => “disable”),
( “host” => “127.0.0.1″, “port” => 9003, “check-local” => “disable”)
)
)
Instead of starting Seaside over Gemstone/S with startSeaside_Hyper <port>, I used the provided script to start 3 gems for fastcgi as per James’ instructions:
miguel@laptop:~$ runSeasideGems start
This started 3 fastcgi gems, listening in ports 9001, 9002 and 9003.
Then I restarted lighttpd:
laptop:~# /etc/init.d/lighttpd restart
Stopping web server: lighttpd.
Starting web server: lighttpd.
And tested that the default index page for lighttpd (located in /var/www/index.html) was served statically (you can add anything here) from the server document root (/var/www/), pointing the browser to:
http://localhost/
Finally, I tested that the /seaside part was correctly delegated to Gemstone/S using FastCGI, pointing the browser to:
http://localhost/seaside
This time I get the dispatcher from Seaside, from where you can navigate the links from Seaside without problems.
This way you can use, for example, blueprint for the CSS style of your app, or maybe TinyMCE, for having a full fledged text editor. All you have to do is to put them in a directory inside the document root of lighttpd (/var/www in this example) and in the Seaside application, you reference them with the absolut path to your website, for example:
http://mysite.com/styles/blueprint.css
or
http://mysite.com/tinymce/jscripts/tiny_mce/tiny_mce.js
So, the webserver to serve the static content of your site (faster) and Seaside to serve your webapp.
Enjoy.


September 28th, 2008 at 4:37 pm
Miguel, Good post with good information! Coincidently I just wrote a Lighttpd post, but they don’t overlap.
September 28th, 2008 at 7:18 pm
Thanks. I would like to propose that the GLASS acronym should become a proper name, as a lot of setups are going to include Lighttpd instead of Apache. Otherwise we’ll have a GLLSS setup that will make the heads of the PHBs explode
.
November 13th, 2008 at 12:04 pm
I think you’re missing the last ) in your lighttpd.conf example above.
November 15th, 2008 at 9:16 pm
Yes, you are right. Fixed. Thanks.
January 24th, 2009 at 5:26 pm
[...] files out of ‘/opt/gemstone/apache/htdocs’. If you are using lighttpd as set up by Miguel Cobá, then files are served out of [...]
January 24th, 2009 at 5:27 pm
[...] I installed GemStone/S 64 2.3 on Slicehost, following James’ instructions for GemStone/S and Miguel Cobá’s instructions for lighttpd. By the time the game highlights were being shown on ESPN, I had copied the [...]
January 24th, 2009 at 5:29 pm
[...] is pretty easy to setup as well. It turns out that Miguel Cobá has just published a post on ‘Gemstone/S and FastCGI with lighttpd‘ where he describes how to set up lighttpd for [...]