Installing Redmine on Mac OS X 10.7 Lion Server

This is a quick summary of the necessary steps for a simple install of Redmine on Apple OS X Lion Server 10.7. This is slightly different from the install for Snow Leopard Server. This is meant only as a supplement, not a replacement, to the official install guide found here.

Install Prerequisites

  1. Install Xcode/OS X Developer Tools
    Either get XCode from the Mac App Store or register for a free account and download from: https://developer.apple.com/downloads/
    An alternative is the latest version of Command Line Tools for XCode https://developer.apple.com/downloads . This is a smaller download and contains all that is necessary for installation.
  2. Install OS X MySQL and associated Libraries
    Download http://www.mysql.com/downloads/mysql/ (select latest 64-bit version, e.g. 5.5.25)
    Run the installation package .pkg file. This will install into /usr/local/mysql/bin
    Run the MySQLStartupItem.pkg file to use GUI to start automatically after startup of your server. (Of course, command line also works.)
    Open the MySQL.prefPane and install for all users. This provides a GUI for starting and stopping. (Of couse, command line also works.)
    Set the root password for your new installation of MySQL. One way is to use the MySQLWorkbench. Or from the command line:
    mysqladmin -u root password NEWPASSWORD (where your password substitutes for NEWPASSWORD)
    Add MySQL to the path. In terminal:
    sudo touch /etc/paths.d/mysql (creates a file in which you type the path)
    sudo nano /etc/paths.d/mysql
    In editor type /usr/local/mysql/bin then save and exit
    Enter startup options to tell the MySQL client and daemon to connect to the local server. In terminal:
    sudo nano /etc/my.cnf
    In editor, add the following as appropriate:
    [mysqld]
    socket = /tmp/mysql.sock
    [client]
    socket = /tmp/mysql.sock

    Install the MySQL binaries. Info about client libraries is available at http://support.apple.com/kb/HT4006 , or to download directly use
    http://www.opensource.apple.com/other/MySQL-55.binaries.tar.gz (or latest version)
    sudo tar -xzvf ~/Downloads/MySQL-55.binaries.tar.gz -C ~/Downloads
    This will produce a root.tar archive, which must then also be extracted:
    sudo tar -xzvf ~/Downloads/MySQL-55.binaries/MySQL-55.root.tar.gz -C /
    If successful, tar should list the many files being placed in appropriate locations throughout the system
  3. Install Phusion Passenger
    This is a gem that handles Ruby on Rails applications and makes them accessible on the web server.
    sudo gem install passenger
    sudo passenger-install-apache2-module
    The apache2 module installation will ask you to add several lines to the apache configuration file. For the standard Lion Server, the file is /etc/apache2/httpd.conf . Typical lines to add are:
    LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
    PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-3.0.12
    PassengerRuby /System/Library/Frameworks/Ruby.framework/Version/1.8/usr/bin/ruby@
    

    It may also be helpful to specify the user that runs passenger, with the line
    PassengerDefaultUser www
  4. Build and install Passenger Pref Pane
    This is a GUI interface for the Mac, to make it easy to add Ruby on Rails applications. Many of the binary prefPanes on the web are not compatible with 10.7, so it is necessary to build :
    cd ~/Downloads
    git clone https://github.com/Fingertips/passengerpane/
    cd passengerpane
    xcodebuild

    (If you can't find xcodebuild, it may be in /usr/bin/xcodebuild)
    Install the preference pane. Look in ~/Downloads/passengerpane/build/Release, and double-click on Passenger.prefPane to install it.
    An alternative is to download a pre-compiled build for 10.7, e.g. SoftwhisperSL-PassengerPrefPane

Install Redmine

  1. Checkout Redmine 2
    cd /Library/WebServer/Sites/
    If the Sites directory doesn't exist, create it (sudo mkdir /Library/WebServer/Sites)
    sudo git clone https://github.com/redmine/redmine
  2. Configure Passenger
    Open /Library/WebServer/Sites in Finder
    Start Passenger preference pane in System Preferences
    Drag redmine folder to Passenger (you may have to 'click to make changes')
    Set "Address" to something like redmine.local and click "Production"
    Enter any aliases for the website, such as your.server.com/redmine
  3. Setup Database with redmine user and database
    mysql -u root -p
    (Enter the MySQL root password when prompted)
    Now enter the following into MySQL, substituting a password of your choice for MYPASSWORD:
    create database redmine character set utf8;
    create user 'redmine'@'localhost' identified by 'MYPASSWORD';
        grant all privileges on redmine.* to 'redmine'@'localhost';
  4. Configure Redmine
    cd /Library/WebServer/Sites/redmine
    sudo mkdir tmp public/plugin_assets
    sudo chown -R _www:_www tmp public/plugin_assets log files
    sudo chmod -R 755 files log tmp public/plugin_assets
    sudo cp config/database.yml.example config/database.yml

    Edit database.yml, e.g.
    production:
      adapter: mysql
      database: redmine
      host: localhost
      username: redmine
      password: MYPASSWORD
      socket: /tmp/mysql.sock

    If necessary, do the same for configuration.yml, for example to set up email SMTP.
  5. Install appropriate gems
    Optional: It helps to have imagemagick, which can be installed with brew install imagemagick if you use Mac Homebrew
    sudo gem install bundler
    Make sure you are in the redmine directory cd /Library/WebServer/Sites/redmine:
    sudo bundle install --without development test
    (If you don't have imagemagick, also append rmagick to the above line)
  6. Establish Defaults
    sudo rake generate_secret_token
    If you get problems in here, it is because above installing official MySQL community edition was installed and the configuration is looking for the one which is distributed using MacPorts. Use the command "sudo port install mysql5-server mysql5" and try it again.
    sudo RAILS_ENV=production rake db:migrate
    sudo RAILS_ENV=production rake redmine:load_default_data

    When prompted, enter the appropriate language (e.g. en for English) and press enter.
    Note: You may receive warning message "Please install RDoc". This does not appear to prevent successful installation. For redmine 1.4, use generate_session_store instead of generate_secret_token.

Configure Apache to serve up Redmine

You may wish to try out using webrick first, but you can move straight to apache.
  1. Go to Server.app, select the Web service, and add a new website. For example domain name redmine.local, and store site files in /Library/WebServer/Sites/redmine/public
  2. Restart the web server
    sudo apachectl restart
    Or, in Server.app, turn the web service off and then on.
    Go to the Passenger prefPane and restart your redmine app
    The site should now be visible, e.g. at redmine.local
    To serve outside of local, instructions may be found here
    For example, to serve as a subdomain from your main server, do the following. First, link the redmine directory into the directory where Server stores files in, e.g.
    ln -s /Library/WebServer/Sites/redmine/public /Library/Server/Web/Data/Sites/Default/redmine
    edit the appropriate .conf file in /etc/apache2/sites, and under VirtualHost add RailsBaseURI /redmine to point at the same location
  3. Login as Admin
    By default, the user:admin has password:admin, which you should change immediately.

Notes

  1. For automated installs, check out How to install Redmine in Linux Windows and OS X using BitNami Redmine Stack
  2. The following references were helpful for compiling this howto:
    http://www.macweb.cz/tag/redmine/
    RedmineInstallOSXServer for Snow Leopard Server
  3. This same procedure also works for Redmine 1.4. Installation for 1.4+ is made vastly easier by the gem bundler, which ensures the appropriate gem versions are maintained.
  4. Redmine 2.0+ requires ruby gems that conflict with some Lion Server web applications such as Wiki and Profile Manager. These require earlier versions of rack (1.2.1) and rails (2.3.14). To run these applications, it is preferable to concurrently run redmine 1.4, which is compatible with older gems, or to manage separate ruby versions for redmine vs Server web apps.
  5. Probably a better idea to use PostgreSQL instead of installing MySQL, which is no longer provided by Apple with OS X Server. There are also alternative methods to install MySQL, such as brew install mysql.