The Joyent Community

A place where the Joyent community can gather, help each other out, and stay informed.

You are not logged in.

#1 2006-05-22 21:08:28

ericpeden
New member
Registered: 2006-05-08
Posts: 2
Expertise

partial HOWTO: Instiki as FastCGI

At the bottom of http://instiki.org/show/Installation there's a note that, as of 0.11.0, Instiki should be able to run as a FastCGI application. I've gotten it to work under lighttpd and thought I'd share my config here. I'm having a bit of trouble mapping URLs the way I want them, though, and I'm hoping someone else will have some insight into that problem.

Assuming you've got lighttpd already setup, configuring Instiki to run as a FastCGI is fairly simple. Once setup this way you won't have to worry about having a cronjob to keep Instiki running: lighttpd will take care of it for you when it launches. My lighttpd runs on port 8010, and here we'll configure Instiki so it's available from http://example.com:8010/instiki . We can then use Apache to proxy requests from our main site through to lighttpd.

If you're starting from scratch, you'll need to obtain a copy of Instiki and setup its database. Let's grab it from Subversion and put it in a folder called "apps":

mkdir apps
cd apps
svn co http://svn.instiki.org/instiki/trunk instiki

Now to initialize the SQLite database:

cd instiki
RAILS_ENV=production rake migrate

Rails apps generally assume they're running at the root URL. However, we want to get to Instiki via http://example.com:8010/instiki, not http://example.com:8010/ . We'll need to let Instiki know this so that it can generate the correct URLs. Open up config/environment.rb. At the bottom of the file add the following line:

Code:

ActionController::AbstractRequest.relative_url_root = "/instiki"


Now Instiki knows where it lives in the URL namespace.

When configuring lighttpd I prefer to keep the configuration for each app/site in its own file, and then just include these files in the main lighttpd.conf. My lighttpd_instiki.conf looks something like this:

Code:

homedir = "/home/YOURUSERNAME"
instiki = homedir + "/apps/instiki"
logdir = homeidr + "/logs"

$HTTP["url"] =~ "^/instiki" {

server.document-root = instiki + "/public/" server.errorlog = logdir + "/instiki.lighttpd-error.log" alias.url = ("/instiki/" => instiki + "/public/" ) url.rewrite = ( "/$" => "index.html", "([^.]+)$" => "$1.html" ) server.error-handler-404 = "/dispatch.fcgi" fastcgi.server = ( ".fcgi" => ( "localhost" => ( "socket" => instiki + "lighttpd-fcgi.socket", "bin-path" => instiki + "/public/dispatch.fcgi", "bin-environment" => ( "RAILS_ENV" => "production" ), "min-procs" => 1, "max-procs" => 1, "idle-timeout" => 60, ) ) ) }


Create the configuration file, reload/restart lighttpd, and verify that you can access Instiki directly. You can now create ProxyPass/ProxyPassReverse pairs in Webmin to bring Instiki into your normal URL space.

Here's what I can't figure out, though: I'd like to make a published version of the Wiki (one that doesn't have edit links visible) the default and hide the editable version behind a different URL. Ideally, the published pages would be visible via http://example.com/wiki, and the edit version would be something like http://example.com/wiki/edit. However, by default the published pages are accessible only via http://example.com/wiki/published, and going to /wiki prompts for a password. I can setup a proxy that points http://example.com/wiki to http://example.com:8010/wiki/published, but all of the links have "/wiki/published" in them so even that doesn't work.

I'm almost positive this requires tweaking Instiki's routes.rb, but I can't bend it to my will. Any suggestions?

Last edited by ericpeden (2006-05-22 21:13:50)

Offline

 

#2 2006-05-24 04:54:33

madams
 
From: Edinburgh
Registered: 2005-05-11
Posts: 2072
Website  Expertise

Re: partial HOWTO: Instiki as FastCGI

Thanks for this. I have a port for lighttpd when I tried setting up Wordpress and Textpattern under lighty just for fun. I had the same kinds of problems with clean-URIs so I gave up.

However, I'm using Instiki for a private online notebook, so niceties like the given URI for a published version are not an issue. I'll give your HOWTO a spin when I get the chance.

One question:

When setting up Instiki I never recall issuing the command

Code:

RAILS_ENV=production rake migrate


.

I'm not up on deploying Rails, and as my Instiki gets traffic only from me, is this necessary?


Mark
Live in the city, work in the country. | OpenSolaris Immigrant

Offline

 

#3 2006-05-24 07:26:15

ericpeden
New member
Registered: 2006-05-08
Posts: 2
Expertise

Re: partial HOWTO: Instiki as FastCGI

madams wrote:

When setting up Instiki I never recall issuing the command

Code:

RAILS_ENV=production rake migrate


I'm not up on deploying Rails, and as my Instiki gets traffic only from me, is this necessary?


The Instiki docs don't mention this, either, but without it I had no database for Instiki to place data in.

I've seen other posts in this forum that suggest 'rake import_db_schema' (or something to that effect) instead, but the results should be equivalent. It may work for you out of the box, though. It just didn't for me.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson