Installing Redmine 2.3.3, mod_passenger on Gentoo
This document describes how to install Redmine via Apache + Passenger or FastCGI, connected to a Subversion code repository with a PostgreSQL backend. The redmine installation will be visible in a sub-directory at http://host/redmine. The installation would be slightly different for an Redmine sub-domain.
Requirements
Set RUBY_TARGETS="-ruby18 ruby19 -ruby20".
After chaging USE flags (like RUBY_TARGETS) you should emerge -aN @world
.
You will need to adjust the keywords in /etc/portage/package.keywords
after trying this command.
emerge -av www-apps/redmine-2.3.2 \ USE="fastcgi -imagemagick -ldap -openid -passenger {-test}" \ RUBY_TARGETS="-ruby18 ruby19"
Installing Passenger
Run this command once to get a list of packges you'll need to unmask.
emerge -av =dev-ruby/daemon_controller-0.2.6 =www-apache/passenger-3.0.7
The packages in this example are specific versions, adjust as necessary for newer packages
dev-ruby/ffi Issues
If there are issues with dev-ruby/ffi the you can try this.
ACCEPTY_KEYWORDS="~amd64" emerge dev-ruby/ffi
That should get you version 1.4.0 which works perfectly, see bug: .
Additional Packages
emerge dev-ruby/nokogiri dev-ruby/rack-openid-1.3.1 dev-ruby/fastercsv dev-ruby/ruby-net-ldap dev-ruby/rmagick dev-ruby/shoulda
Update the Gemfile to point to jquery-rails 2.3.0, gem "ruby-openid", "~> 2.2.3", :require => "openid"
Edit fastercsv Ebuild to allow RUBY_TARGETS="ruby19", then rebuild it: Bug:.
# required by dev-ruby/ruby-net-ldap (argument) =dev-ruby/ruby-net-ldap-0.3.1 ~amd64~ # emerge -av www-apache/passenger [ebuild N ] dev-libs/libev-4.04 USE="-static-libs" 461 kB [ebuild N ~] dev-ruby/daemon_controller-0.2.6 USE="-test" RUBY_TARGETS="-ree18 ruby18" 22 kB [ebuild U ~] www-apache/passenger-3.0.7 [2.2.15] USE="-debug -doc -test%" RUBY_TARGETS="ruby18%*" 2,765 kB
Let that complete, then update /etc/conf.d/apache2
to have -D PASSENGER
, similar to the following example.
APACHE2_OPTS="-D SSL -D PHP5 -D PASSENGER"
Adjust the Apache configuration for Passenger in /etc/apache2/modules.d/30_mod_passenger.conf
as necessary (defaults may be OK).
Then configure your Redmine similar to this example which shows Redmine in a sub-directory.
<Location /redmine> Options Indexes -ExecCGI FollowSymLinks MultiViews # AllowOverride None Order allow,deny Allow from all # mod_rails # PassengerUser redmine RailsEnv live RailsBaseURI /redmine # environment.rb # Redmine::Utils::relative_url_root = "/redmine" </Location>
Install FastCGI & Redmine
Unmask Redmine and a few of it's dependencies, they are not marked stable yet
~ # echo "dev-ruby/coderay ~amd64" >> /etc/portage/package.keywords ~ # echo "dev-ruby/i18n ~amd64" >> /etc/portage/package.keywords ~ # echo "dev-ruby/ruby-net-ldap ~amd64" >> /etc/portage/package.keywords ~ # echo "www-apps/redmine ~amd64" >> /etc/portage/package.keywords
Be sure to set USE flags accordingly, such as USE="fastcgi postgres sqlite3 subversion".
~ # emerge -av www-apache/mod_fastcgi redmine These are the packages that would be merged, in order: Calculating dependencies ... done! [ebuild N ] www-apache/mod_fastcgi-2.4.7_pre0910052141 101 kB [ebuild N ] dev-ruby/rubygems-1.3.7-r1 USE="-doc -server" RUBY_TARGETS="-jruby -ree18 ruby18" 285 kB [ebuild N ] dev-ruby/i18n-0.4.2 USE="-test" RUBY_TARGETS="-jruby -ree18 ruby18" 65 kB [ebuild N ] dev-ruby/ruby-net-ldap-0.0.4-r1 USE="-test" RUBY_TARGETS="-jruby -ree18 ruby18" 41 kB [ebuild N ] dev-ruby/coderay-0.9.7 USE="-doc -test" RUBY_TARGETS="-jruby -ree18 ruby18 (-ruby19)" 103 kB [ebuild N ] dev-ruby/activesupport-2.3.5 USE="-doc" 401 kB [ebuild N ] dev-ruby/ruby-postgres-0.7.9.20080128-r1 USE="-test" RUBY_TARGETS="ruby18" 32 kB [ebuild N ] dev-ruby/sqlite-ruby-2.2.3-r2 USE="-test" RUBY_TARGETS="ruby18" 41 kB [ebuild N ] dev-libs/fcgi-2.4.1_pre0311112127 USE="-html" 460 kB [ebuild N ] dev-ruby/activerecord-2.3.5 USE="-doc -mysql postgres -sqlite sqlite3" 534 kB [ebuild N ] dev-ruby/ruby-fcgi-0.8.8 USE="-test" RUBY_TARGETS="-jruby ruby18" 13 kB [ebuild N ] www-apps/redmine-1.1.1 USE="-cvs -darcs fastcgi git -imagemagick -mercurial -mysql -openid -passenger postgres sqlite3 subversion -test" RUBY_TARGETS="ruby18" 4,720 kB Would you like to merge these packages? [Yes/No]
~ # gem install pg
Ensure that mod_fastcgi is properly loaded by Apache
Symlink or copy redmine dispatcher to your webroot
~ # cp -a /var/lib/redmine/public /var/www/example.com/webroot/redmine ~ # chmod 0755 /var/www/example.com/webroot/redmine/dispatch.fcgi
Configure Apache Directory/Location Rewrite Rules
~ # cat /etc/apache2/vhosts.d/redmine.conf <Location /redmine> Options Indexes ExecCGI FollowSymLinks MultiViews Order allow,deny Allow from all # Doesn't Work :( SetEnv RAILS_ENV live SetEnv RAILS_RELATIVE_URL_ROOT /redmine RewriteEngine On RewriteBase /redmine # RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] </Location>
Configure Redmine
Change ownership of necessary directores
~ # cd /var/lib/redmine ~ # chown -R apache:apache files public/public_assets/ tmp/ /var/log/redmine
Create / Update Configuration, edit database.yml
, settings.yml
as necessary.
These files are located in /var/lib/redmine/config, the names used represent an installed base, so multiple redmines can be served from the same code base.
~ # cat database.yml live: adapter: postgresql database: my_redmine host: sql.domain.tld username: redmine password: redmine_pw encoding: utf8
And we need to update some configuration data for Redmine, use the additional_environment.rb file.
~ # cat additional_environment.rb config.action_controller.session = { :key => "_my_redmine", :secret => "b8c98c891a2fcd9c268154f05b43c4" }
Use something like this command to generate a reasonable key.
~ # echo 'this is how I generate a key' | sha512sum |cut -b1-30 1eac0100cf4f009390fb3b683e8b8edd
Create the database
~ # psql CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'my_password' NOINHERIT VALID UNTIL 'infinity'; CREATE DATABASE my_redmine WITH ENCODING='UTF8' OWNER=redmine;
And add the schema and base-data
~ # cd /var/lib/redmine RAILS_ENV=live rake db:migrate
When using FastCGI, we had to add this option to the end of environment.rb
, possibiliy because of the sub-directory installation method.
Redmine::Utils::relative_url_root = "/redmine"
Create Database in Sqlite3
~ # cat database.yml production: adapter: sqlite3 dbfile: /opt/company/var/redmine.sqlite3 ~ # rake db:migrate RAILS_ENV="live"
Create Database in PostgreSQL
~ # cat database.yml live: adapter: pgsql dbfile: ~ # rake db:migrate RAILS_ENV="live"
Watch Log Files
~ # tail -f /var/log/apache2/*log /var/log/redmine/*log
Login as Admin
Login to the system using the default authentication of admin / admin. Update the password (in My Account) and then create the projects. Then go to the Administration section, load the default work flow and begin defining your environment.
Turn Down Logging Now
There is loads of logging in redmine, turn this down to save disk I/O.
~ # cat additional_environment.rb # This can be used if you don't have logrotate (should!) # Logger.new(PATH,NUM_FILES_TO_ROTATE,FILE_SIZE) # config.logger = Logger.new(config.log_path, 2, 1000000) config.logger.level = Logger::INFO
Apache Proxy to Mongrel
Much the same as above install Redmine and configure it properly. Update the Apache configuration to proxy requests to Mongrel services, make sure that ports and hostnames match up. This one has two services, balanced.
Start the Mongrel Services
~ # ruby /usr/bin/mongrel_rails start \ -c /var/www/redmine \ -a localhost -p 10600 -e production \ -d --user www-data --group www-data \ -P /var/run/mongrel/mongrel.10600.pid \ -l /var/log/mongrel.10600.log ~ # ruby /usr/bin/mongrel_rails start \ -c /var/www/redmine \ -a localhost -p 10601 -e production \ -d --user www-data --group www-data \ -P /var/run/mongrel/mongrel.10601.pid \ -l /var/log/mongrel.10601.log
Now configure Apache to Proxy requests to these two Mongrel services
ProxyPass / balancer://redmine_cluster/ ProxyPassReverse / balancer://redmine_cluster/ <Proxy balancer://redmine_cluster> BalancerMember http://localhost:10600 BalancerMember http://localhost:10601 </Proxy>