July 6, 2021 . 6 MIN READ
This is an update to my earlier installation guide for Redmine 1.1.0.
The new Redmine 2.0.0 release now supports Rails 3.2.3 and that, along with a few other changes, makes the installation route slightly different.
As stated before, I AM NOT a Linux/Ubuntu guru, so any mistakes are of my own making and I’d appreciate any feedback to make the installation better/clearer.
So, with all that said, here goes:
I know that Redmine can be installed as a package in Ubuntu, but it doesn’t appear to be the latest version (1.4.2 at the time of writing). So I’m taking the longer route to get it working, as I couldn’t get it to configure the way I want. It does have the advantage that I’m using the very latest version straight from RubyForge.
For this install, I’m using a fresh install of Ubuntu 12.04 LTS, configured as a LAMP server, so Apache, MySQL & PHP are already installed.
Get into the folder where we’re going to install & configure Redmine from:
cd /usr/share
Now we’re going to download the latest version of Redmine from RubyForge:
sudo wget http://rubyforge.org/frs/download.php/76134/redmine-2.0.0.tar.gz
Unpack the archive:
sudo tar xvfz redmine-2.0.0.tar.gz
And tidy things up a little:
sudo rm redmine-2.0.0.tar.gzsudo mv redmine-2.0.0 redmine
We also need to adjust some of the ownership of the folders
sudo chown -R root:root /usr/share/redmine
However, we need to make sure that a particular file is set to www-data as owner. This is because Passenger runs as the user that owns this file.
sudo chown www-data /usr/share/redmine/config/environment.rb
We’ll create a symbolic link from the main website home back to our actual Redmine application directory:
sudo ln -s /usr/share/redmine/public /var/www/redmine
Now create the database:
sudo mysql -u root -p
This will prompt you for the password for the ‘root’ MySql account you created when you installed MySql.
The prompt will change to:
mysql>
Now enter the following, line by line:
CREATE DATABASE redmine character SET utf8;CREATE user ‘redmine’@’localhost’ IDENTIFIED BY ‘my_password’;GRANT ALL privileges ON redmine.* TO ‘redmine’@’localhost’;
Type exit to leave the MySQL prompt.
Now configure the database:
sudo cp redmine/config/database.yml.example redmine/config/database.yml
Run nano or your favourite editor and edit it to the following:
sudo nano redmine/config/database.ymlproduction: adapter: mysql2 database: redmine host: localhost username: redmine password: my_password encoding: utf8
NOTE: Make sure you change the adapter to mysql2! I spent HOURS trying to debug this issue.
NOTE: Don’t forget to change my_password to a password of your own choosing and that it matches what you configured in the MySQL database.
Firstly install all the required libraries:
sudo apt-get install ruby1.9.3 libmysqlclient-dev
If you’re going to use RMagick (to enable Gantt export to png image), you’ll need to add these libraries:
sudo apt-get install libmagickcore-dev libmagickwand-dev
New to Redmine version 1.4.0 and above is support the Bundler to install all the Ruby Gems needed by Redmine.
Enter the following to install Bundler:
sudo gem install bundler
Change into the redmine directory to run Bundler to install our Gems:
cd redmine
As we’ll only be configuring for MySQL, our Bundler needs to know NOT to include Postgre and SQLite.
sudo bundle install –without development test postgresql sqlite
NOTE: If you’re not going to use ImageMagick then change the line to read:
sudo bundle install –without development test postgresql sqlite rmagick
Configure Redmine:
sudo rake generate_secret_tokensudo RAILS_ENV=production rake db:migrate sudo RAILS_ENV=production rake redmine:load_default_data
When the last command completes, it will prompt to choose your language. Type the code for the best match to your country & press Enter.
We now need to configure correct directory permissions:
sudo mkdir public/plugin_assetssudo chown -R www-data:www-data files log tmp public/plugin_assetssudo chmod -R 755 files log tmp public/plugin_assets
Test Redmine:
sudo ruby script/rails server webrick -e production
If you enter your webaddress:http://my_website:3000 you should see the Redmine homepage.
If all is well at this point, we can now configure Passenger to make sure it launches when Apache runs.
Install & Configure Passenger:
sudo gem install passenger
Before we can install the Passenger module, we need some additional software:
sudo apt-get install libcurl4-openssl-dev libssl-dev apache2-prefork-dev libapr1-dev libaprutil1-dev
Now we are set to install the Passenger module for Apache:
sudo passenger-install-apache2-module
Passenger will run & compile the source code into the module for Apache.
Now use nano or your favourite editor to create the loader:
sudo nano /etc/apache2/mods-available/passenger.loadLoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
Make a link to make the module enabled:
sudo ln -s /etc/apache2/mods-available/passenger.load /etc/apache2/mods-enabled/passenger.load
Now create a configuration file for Passenger:
sudo nano /etc/apache2/mods-available/passenger.confPassengerRoot /var/lib/gems/1.9.1/gems/passenger-3.0.12PassengerRuby /usr/bin/ruby1.9.1
Now configure Apache for our new site:
sudo nano /etc/apache2/sites-available/mysite<VirtualHost *:80> ServerName my_domain.com DocumentRoot /var/www/redmine ServerAdmin user@example.com LogLevel warn ErrorLog /var/log/apache2/redmine_error CustomLog /var/log/apache2/redmine_access combined <Directory /var/www/redmine> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all RailsBaseURI /redmine PassengerResolveSymlinksInDocumentRoot on </Directory></VirtualHost>
We also need to tell Apache how to configure Passenger:
sudo nano /etc/apache2/apache2.conf
Add the following line at the end of the file:
Include /etc/apache2/mods-available/passenger.conf
Finally, enable the site:
sudo ln -s /etc/apache2/sites-available/mysite /etc/apache2/sites-enabled/mysite
Remove the default site:
sudo rm /etc/apache2/sites-enabled/000-default
Make sure the Passenger module is enabled:
sudo a2enmod passenger
And, restart Apache:
sudo service apache2 restart
If everything went well, then you should be able to see Redmine in your browser:
http://my_website
Configure Subversion
We need to install the necessary packages before we start:
sudo apt-get install subversion libapache2-svn libapache2-mod-perl2
We need to copy the Perl script from Redmine to somewhere it can be accessed:
sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache/Redmine.pm
Create the site description for our Subversion HTTP access:
sudo nano /etc/apache2/sites-available/svn
Enter the following details:
# /svn location for usersPerlLoadModule Apache::Redmine<Location /svn> DAV svn SVNParentPath “/var/svn” Order deny,allow Deny from all Satisfy any PerlAccessHandler Apache::Authn::Redmine::access_handler PerlAuthenHandler Apache::Authn::Redmine::authen_handler AuthType Basic AuthName “Redmine SVN Repository” #read-only access <Limit GET PROPFIND OPTIONS REPORT> Require valid-user Allow from my_domain.com Allow from localhost Satisfy any </Limit> # write access <LimitExcept GET PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept> ## Mysql-Settings RedmineDSN “DBI:mysql:database=redmine;host=localhost” RedmineDbUser “redmine” RedmineDbPass “my_password”</Location>
Now setup our repository directory:
sudo mkdir -p /var/svnsudo chown -R www-data:www-data /var/svnsudo chmod 0750 /var/svn
Now you need to log into Redmine, then select Administration->Settings->Repositories.
Tick the ‘Enable WS for repository management’ option and then click ‘Generate a key’. Remember to click ‘Save’ to store all the settings.
Now run the following code, entering the data that is correct for your site & key:
ruby /usr/share/redmine/extra/svn/reposman.rb –redmine my_domain.com –svn-dir /var/svn –owner www-data –url http://my_domain.com/svn –verbose –key=my_api_key
This should query your Redmine installation and attempt to create a project directory under the repository root you specified. As this isn’t being run as root this will fail, but that’s fine.
Now set this up so it’ll automatically check for any new projects & create any necessary repositories:
sudo crontab -e
Add the following at the end:
*/10 * * * * ruby /usr/share/redmine/extra/svn/reposman.rb –redmine my_domain.com –svn-dir /var/svn –owner www-data –url http://my_domain.com/svn –verbose –key=my_api_key
Now enable the site:
sudo ln -s /etc/apache2/sites-available/svn /etc/apache2/sites-enabled/svn
Finally, restart Apache
sudo service apache2 restart
And that’s all…finally! 🙂