Binary Static

How to install Redmine from SVN with Apache Passenger and Postgresql

Posted in Applications, Linux, SysAdmin, Web by Chris on September 1, 2012

System: debian 6.0.5

Redmine’s standard debian packages are pretty outdated, so here’s how I installed its latest stable version. I used postgresql as database.

Get the latest stable version from the projects subversion. Do a checkout and keep the .svn directory for later updates on this branch:

# svn co http://redmine.rubyforge.org/svn/branches/2.0-stable /usr/share/redmine

Make sure ruby and rubygems and necessary libraries are installed:

# apt-get install ruby rubygems libpq-dev libmagickcore-dev libmagickwand-dev

Install bundler, which is ruby’s dependency manager, and rake, which is its build tool and conveniently to their executables:

# gem install bundler
# ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle
# gem install rake
# ln -s /var/lib/gems/1.8/bin/rake /usr/local/bin/rake

Change to the Redmine root directory and install all needed libraries with bundler:

# bundle install --without development test mysql sqlite

Configure /usr/share/redmine/config/database.yml:

production:
  adapter: postgresql
  database: redmine
  host: localhost
  username: redmine
  password: password
  encoding: utf8

Create the role and user in the postgresql database:

# su postgres
$ psql
postgres=# CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD \
'password' NOINHERIT VALID UNTIL 'infinity';
postgres=# CREATE DATABASE redmine WITH ENCODING='UTF8' \
OWNER=redmine;

Logout from the database and its user and generate the session token (again as root in /usr/share/redmine):

# rake generate_secret_token

Generate the database schema and load the fixtures:

# RAILS_ENV=production rake db:migrate
# RAILS_ENV=production rake redmine:load_default_data

Allow the Apache user (assuming www-data) access to relevant directories:

# mkdir tmp public/plugin_assets
# sudo chown -R redmine:redmine files log tmp public/plugin_assets
# sudo chmod -R 755 files log tmp public/plugin_assets

Test your installation by starting the built-in-server webrick, stop it with Ctrl-C:

# ruby script/rails server webrick -e production

Configure the named virtual host in
/etc/apache2/sites-available/tracking.codeways.org:

<VirtualHost *:80>
     ServerName tracking.codeways.org
     ServerAdmin admin@codeways.org

     DocumentRoot /usr/share/redmine/public

     RailsEnv production
     RailsBaseURI /
     <Location "/">
         Options ExecCGI FollowSymLinks
         Order allow,deny
         Allow from all
     </Location>
</VirtualHost>

At first, I linked to the Redmine root directory. This became unnecessary as I made it the document root of the vhost:

# ln -s /usr/share/redmine/public /srv/tracking.codeways.org

I configured e-mail (using exim4 and tls) in /usr/share/redmine/config/configuration.yml:

default:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      enable_starttls_auto: true
      address: mail.codeways.org
      port: 25
      domain: mail.codeways.org
      authentication: :plain
      user_name: "redmine"
      password: password

Start Redmine by restarting Apache:

# a2ensite tracking.codeways.org
# /etc/init.d/apache2 restart

Log into Redmine under http://tracking.codeways.org. Default username admin and password admin.

Tagged with:

Install Redmine on Debian Squeeze with Apache Passenger

Posted in Applications, Linux, SysAdmin, Web by Chris on August 30, 2012

This is how I installed redmine on my server, which runs debian 6.0.5. Get the packages:

# apt-get install redmine redmine-sqlite rails rake ruby \
librmagick-ruby libapache2-mod-passenger ruby-passenger

Debian should activate the passenger module during install.  Also during install you should set the defaults for the database module. This should be simple if you use sqlite3.  Strangely enough, the package does not touch a log file for the production environment.  I did this manually:

# mkdir /usr/share/redmine/log/log
# touch /usr/share/redmine/log/production.log

Try running webrick; kill with Ctrl+C:

# cd /usr/share/redmine
# ruby script/server -e production

At first I symlinked to the public directory of redmine.  Yet, this seems to have become unneccessary later:

# ln -s /usr/share/redmine/public /srv/tracking.codeways.org

Create a named virtual host /etc/apache2/sites-available/tracking.codeways.org:

<VirtualHost *:80>
     ServerName tracking.codeways.org
     ServerAdmin admin@codeways.org

     DocumentRoot /usr/share/redmine/public

     RailsEnv production
     RailsBaseURI /
     <Location "/">
         Options ExecCGI FollowSymLinks
         Order allow,deny
         Allow from all
     </Location>
</VirtualHost>

Configure e-mail service (exim4, tls) in /etc/redmine/default/email.yml:

production:
  delivery_method: :smtp
  smtp_settings:
    ssl: true
    enable_starttls_auto: true
    address: mail.codeways.org
    port: 25
    domain: mail.codeways.org
    authentication: :plain
    user_name: "redmine"
    password: password

Activate the whole she-bang:

# a2ensite tracking.codeways.org
# /etc/init.d/apache2 restart

Start redmine with http://tracking.codeways.org. Default username admin and password admin.

Tagged with:

Interleaving two PDF files…

Posted in Applications, Hacking, Linux by Chris on October 17, 2010

Lightbulb…with no scripting required.  You’ll need the pdftk package though.  Say you’ve got a PDF file that has a two-sided layout and you want to trim the pages.  You could do this with pdfnup — however, your file may cut off from the even pages what it adds to the odd ones.  What now?  The solution is simple:

1. Use pdftk to split the file in even and odd pages seperately:

pdftk in.pdf cat 1-endeven output out.even.pdf
pdftk in.pdf cat 1-endodd output out.odd.pdf

2. Now would be the time to apply some pdfnup trimming magic to the two new files.

3. Use pdftk to burst these two files into single pages:

pdftk out.odd.pdf burst output %04d_A.pdf
pdftk out.even.pdf burst output %04d_B.pdf

4. Use pdftk to merge the pages back into one file, e.g.:

pdftk *.pdf cat output out.pdf

The important point here lies in step 3 when appending A or B to the odd and even page file names, because this allows glob sorting the pages like 0001_A.pdf 0001_B.pdf 0002_A.pdf 0002_B.pdf and so on.  I can’t believe I started to write a script before I realized how to solve this the simple way…

Tagged with: , , ,

Launching OpenOffice faster

Posted in Applications by Chris on January 19, 2010

I’m not a big fan of office suite software packages and try to avoid using them where I can.  Today I learned something that eased my pain with OpenOffice: you can launch it way faster.  How?  By turning off an option which triggers  a Java Runtime Environment (!) in the background: Extras > Options > OpenOffice.org > Java.  In my opinion this option should be turned off by default, given that a majority of users won’t script Java macros on a regular basis anyway.

Tagged with: