The GnuTLS trac installation is in a poor shape. To fix that, I looked into alternatives and found Redmine. Redmine appears to do most things that I liked in Trac (wiki, roadmap and issue tracking) plus it supports more than one project (would come in handy for my other projects) and has built-in git support. I would like to see better spam handling and OpenID support, but it is good enough for our purposes now, and there are similar concerns with trac.
However, getting it up and running with lighttpd on a modern debian lenny installation was not trivial, and I needed some help from #redmine (thanks stbuehler). After finally getting it up and running, I made a copy of the machine using rsync and rsnapshot, so I could re-create a working configuration if I get stuck, and then re-installed the virtual machine.
The notes below are the steps required to set up Redmine using Lighttpd and MySQL on a Debian Lenny. I’m posting this to help others searching for the error messages I got, and to help my own memory in case I need to re-install the server sometime.
I assume you have installed Debian Lenny, and have root access to it. You need to install some dependencies:
apt-get install mysql-server rails lighttpd
apt-get install librmagick-ruby
apt-get install subversion git-core
It is highly recommend to set a password on the MySQL root account, for example:
# /usr/bin/mysql -u root -D mysql -e “update user set password=password(‘foobar’) where user=’root'”
# /usr/bin/mysql -u root -e “flush privileges”
There are official Redmine installation instructions, and these steps follow them but contains more details.
First, create a database for Redmine and set up a MySQL user, like this:
li37-61:~# mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 31
Server version: 5.0.51a-15 (Debian)Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.
mysql> create database redmine character set utf8;
Query OK, 1 row affected (0.00 sec)mysql> GRANT SELECT,INSERT,UPDATE,DELETE,INDEX,ALTER ON redmine.* TO ‘rbuser’@’localhost’ IDENTIFIED BY ‘barfoo’;
Query OK, 0 rows affected (0.00 sec)mysql>
Then download and install Redmine.
You could check out the code using SVN although I chosed to use a stable release. I created a new user for the redmine installation, to reduce root account usage.
adduser –disabled-password redmine
su redmine
wget http://rubyforge.org/frs/download.php/39477/redmine-0.7.3.tar.gz
tar xfz redmine-0.7.3.tar.gz
ln -s redmine-0.7.3 redmine
Modify the file redmine*/config/database.yml to read:
production: adapter: mysql database: redmine host: localhost username: rbuser password: barfoo encoding: utf8
You should now setup the database, however I got the following error at this point:
redmine@li37-61:~/redmine$ rake db:migrate RAILS_ENV=”production”
(in /home/redmine/redmine)
rake aborted!
No such file or directory – /tmp/mysql.sock(See full trace by running task with –trace)
redmine@li37-61:~/redmine$
The problem is that you need the Ruby MySQL wrappers. This isn’t really clear from the error message. Install it using:
# apt-get install libmysql-ruby
Now re-run the database setup as the redmine user.
redmine@li37-61:~/redmine$ rake db:migrate RAILS_ENV=”production
…
redmine@li37-61:~/redmine$ rake redmine:load_default_data RAILS_ENV=”production”
(in /home/redmine/redmine-0.7.3)Select language: bg, cs, da, de, en, es, fi, fr, he, hu, it, ja, ko, lt, nl, no, pl, pt, pt-br, ro, ru, sr, sv, th, uk, zh, zh-tw [en]
====================================
Default configuration data loaded.
redmine@li37-61:~/redmine$
At this point you should be able to test the Redmine installation using:
ruby script/server -e production
Shut it down before you continue with next steps.
Create a file called /etc/lighttpd/conf-available/20-redmine.conf and put the following in it. Change the filename and hostname as appropriate, but be sure the change commands later on.
server.modules += ( "mod_fastcgi" ) $HTTP["host"] == "redmine.josefsson.org" { server.document-root = "/home/redmine/redmine/public/" fastcgi.server = ( ".fcgi" => (( "bin-path" => "/home/redmine/redmine/public/dispatch.fcgi", "socket" => "/tmp/ruby-rails.socket", "max-procs" => 5, "idle-timeout" => 20, "bin-environment" => ( "RAILS_ENV" => "production", "RAILS_ROOT" => "/home/redmine/redmine" ), )) ) magnet.attract-physical-path-to = ( "/home/redmine/cleanurl.lua" ) }
Enable the module using:
# lighttpd-enable-mod redmine
You will also need to create a FastCGI wrapper:
li37-61:/home/redmine/redmine/public# cp dispatch.fcgi.example dispatch.fcgi
li37-61:/home/redmine/redmine/public# chmod +x dispatch.fcgi
At this point, it can be useful to tail the various log files, I’m using a command like:
tail -F /var/log/lighttpd/access.log /var/log/lighttpd/error.log /home/redmine/redmine/log/production.log
Starting the lighttpd server at this point results in an error message:
li37-61:~# /etc/init.d/lighttpd restart
Stopping web server: lighttpd.
Starting web server: lighttpd.
li37-61:~#
2008-10-17 04:50:03: (mod_fastcgi.c.1047) the fastcgi-backend /home/redmine/redmine/public/dispatch.fcgi failed to start:
2008-10-17 04:50:03: (mod_fastcgi.c.1051) child exited with status 9 /home/redmine/redmine/public/dispatch.fcgi
2008-10-17 04:50:03: (mod_fastcgi.c.1054) If you’re trying to run PHP as a FastCGI backend, make sure you’re using the FastCGI-enabled version.
You can find out if it is the right one by executing ‘php -v’ and it should display ‘(cgi-fcgi)’ in the output, NOT ‘(cgi)’ NOR ‘(cli)’.
For more information, check http://trac.lighttpd.net/trac/wiki/Docs%3AModFastCGI#preparing-php-as-a-fastcgi-programIf this is PHP on Gentoo, add ‘fastcgi’ to the USE flags.
2008-10-17 04:50:03: (mod_fastcgi.c.1358) [ERROR]: spawning fcgi failed.
2008-10-17 04:50:03: (server.c.908) Configuration of plugins failed. Going down.
FastCGI modules are not installed by default, so you will need to install them:
li37-61:~# apt-get install libfcgi-ruby1.8
Restarting the server again, and accessing dispatch.fcgi using your browser, will result in errors like:
Status: 500 Internal Server Error
No route matches “/dispatch.fcgi” with {:method=>:get}
Solving this is the most complicated part, and I’m not sure whether there are better solutions. Here is what I did. First, install lighttpd’s mod-magnet:
# apt-get install lighttpd-mod-magnet
# lighttpd-enable-mod magnet
Then get a small script to invoke dispatch.fcgi properly:
cd /home/redmine
wget http://nordisch.org./cleanurl.lua
For reference, the contents of the script is:
-- little helper function function file_exists(path, ftype) local attr = lighty.stat(path) return (attr and attr[ftype]) end function check_path(path) local rv = path if (not file_exists(path, "is_file")) then rv = nil local html_file = path .. ".html" if (file_exists(html_file, "is_file")) then rv = html_file else -- handle directory indeces -- we first check if we have a dir and than look for an index.html local index_file = path .. "/index.html" if (file_exists(path,"is_dir") and file_exists(index_file, "is_file")) then rv = index_file end end end if rv then lighty.env["physical.path"] = rv end return rv end -- the magic ;) if (not check_path(lighty.env["physical.path"])) then -- file still missing. pass it to the fastcgi backend lighty.env["uri.path"] = "/dispatch.fcgi" lighty.env["physical.rel-path"] = lighty.env["uri.path"] lighty.env["request.orig-uri"] = lighty.env["request.uri"] lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"] end -- fallthrough will put it back into the lighty request loop -- that means we get the 304 handling for free. ;) -- debugging code -- print ("final file is " .. lighty.env["physical.path"])
At this point, you should be able to restart lighttpd and access your server successfully!
If you get permission errors such as:
Status: 500 Internal Server Error
file /home/redmine/redmine-0.7.3/tmp/sessions//ruby_sess.c06b5f395568fd87 not readable
You need to re-run these commands:
li37-61:/home/redmine/redmine-0.7.3# chgrp -R www-data files log tmp
li37-61:/home/redmine/redmine-0.7.3# chmod -R 775 files log tmp
Happy hacking!
Hi!
I ran into the same problems as you, so thanks for the HOWTO, it saved me hours. But unfortunately, the last step (the magic with the lua script) didnt work for me, so i started to read the rubyonrails wiki, on how the URL handling of rails works, and i found, that rails wants to handle the url itself (at least this rails app), so we should pass the whole url unchanged to redmine, and dont try to handle it. The solution is to set the error-handler to “/dispatch.fcgi”. My problem was solved after adding two lines to the 20-redmine.conf file (and removing the lua script):
server.indexfiles = ( “index.html” ) #this file does not exists
server.error-handler-404 = “/dispatch.fcgi” #so we will use this all the time
I hope it will be useful to somebody 🙂
greetings:
Gábor
Thanks Simon for the trick, the rails app i was trying to install (http://getontracks.org/) finally works.
@Gabor: this fix didn’t work with tracks
I use the following (after server.document-root):
server.indexfiles = ( “dispatch.fcgi”, “index.html” )
server.error-handler-404 = “/dispatch.fcgi”
There ist no need for rewriting the url with Lua.
Pingback: SheevaPlug: Instalando Redmine « simonpena.com
Thanks, this worked for me…but in a roundabout way…I was just ggetting 500 errors on my modules page,when it wouldn’t load.
Hi. I try to use subj. but have a problem with lighttpd reload. When i do command /etc/init.d/lighttpd restart, i have twice of ruby processes. If i reload again, i have three times of processes. How i can fix this. For normally work i must do command: killall -4 ruby, then restart or reload lighttpd
At start i use internal WEBrick, but now i must deploy 3 sites on php… at server where i use redmine