General

Upgrading Redmine at HostGator

Attention: open in a new window. PDFPrintEmail

Last Updated on Tuesday, 22 March 2011 17:34 Written by Stefan Rådström Thursday, 03 March 2011 11:09

Since my installation of Redmine v1.0 there have been a new release to v1.1.

These are the steps that I performed when upgrading Redmine at a HostGator "Shared Web Hosting"-account with SSH-access activated;

I chosed to be very careful in my upgrade, therefore I have deviated a little bit from the schema for upgrading Redmine. That way I assured myself that I always had a relatively simple way to undo any changes that failed, and that any version upgrades to the configuration files are preserved.

First of all I made sure to backup the Redmine database and the entire Redmine site before doing anything else. For this I have a local install of MySQL and putty, which made it easy to create scripts for automatic backup, e.g.:

C:\> mysqldump --defaults-extra-file=my.ini --host=%DBHOST% --user=%DBUSER% --databases %DBNAME% > %DBNAME%.sql
C:\> plink -load MyHostGatorAccount "cd %SITEDIR% ; tar -cf - . | gzip -c" > %FILENAME%.tar.gz

(The --defaults-extra-file=my.ini is for the password only, so it can contain any character, even '>', '|', etc.).

Then I opened a terminal window to your HostGator-account using SSH (with PuTTY for example) to perform the following commands:

  1. $ cd ~/rails_apps/
  2. $ svn co http://redmine.rubyforge.org/svn/branches/1.1-stable redmine-1.1
  3. $ cd ~/rails_apps/redmine-1.1/
  4. $ cp -i ~/rails_apps/redmine-1.0/config/database.yml ~/rails_apps/redmine-1.1/config/
  5. $ cp -i ~/rails_apps/redmine-1.0/config/email.yml ~/rails_apps/redmine-1.1/config/
  6. $ cp -i ~/rails_apps/redmine-1.0/files/* ~/rails_apps/redmine-1.1/files/
  7. $ cp -i ~/rails_apps/redmine-1.0/public/.htaccess ~/rails_apps/redmine-1.1/public/
  8. $ pico ~/rails_apps/redmine-1.1/config/environment.rb
  9. Make sure that the following commands are activated (add them if necessary):
    ENV['GEM_PATH'] = '/home/acctname/ruby/gems:/usr/lib/ruby/gems/1.8'
    ENV['RAILS_ENV'] = 'production'
    # ENV['RAILS_RELATIVE_URL_ROOT'] = "/redmine" # Not necessary if Redmine is put under a sub-domain, e.g. "http://redmine.acctname.com/"
  10. $ cd ~/rails_apps/redmine-1.1/tmp/
  11. $ rails -d mysql --with-dispatchers tmpredmine
  12. $ cp -i tmpredmine/public/dispatch.* ~/rails_apps/redmine-1.1/public/
  13. $ rm -rf tmpredmine
  14. $ cd ~/rails_apps/redmine-1.1/
  15. $ rake generate_session_store
  16. $ rake config/initializers/session_store.rb
  17. $ rake db:migrate RAILS_ENV=production
  18. $ rake db:migrate:upgrade_plugin_migrations RAILS_ENV=production
  19. $ rake db:migrate_plugins RAILS_ENV=production
  20. $ rake tmp:cache:clear
  21. $ rake tmp:sessions:clear
  22. $ unlink redmine; ln -s redmine-1.1 redmine
  23. Restart Redmine. (Login to your HostGator account, look under "Processes Running" in the "Statistics" widget, and select the "View All Processes" link; then kill the "/usr/bin/ruby dispatch.fcgi" process).
  24. Point your web brower to Redmine:
    http://acctname.com/redmine/
    -- or (depending on your configuration) --
    http://redmine.acctname.com/
  25. Make sure that Redmine starts up and works correctly in its basic configuration.
  26. Install (and update) your plugins, one at a time, and make sure that Redmine still works after each installed plugin, e.g.:
    $ cd ~/rails_apps/redmine/vendor/plugins/
    $ wget http://www.redmine.org/attachments/5472/redmine_screenshot_paste-1.1.1.zip
    $ unzip redmine_screenshot_paste-1.1.1.zip
    $ cd ~/rails_apps/redmine/
    $ rake db:migrate_plugins RAILS_ENV=production
    Restart Redmine.
  27. Remember that cloning of git packages is not possible at HostGator - one have to clone them on the local computer, and then upload the folders to "~/rails_apps/redmine/vendor/plugins/" at the HostGator shared account.
  28. Done!

 

For more info, see:

Comment (0) Hits: 2523
 

Installing Redmine at HostGator

Attention: open in a new window. PDFPrintEmail

Last Updated on Monday, 09 May 2011 09:53 Written by Stefan Rådström Thursday, 23 September 2010 09:04

These are the steps that I performed when installing Redmine with Mercurial as SCM (distributed revision controll) at a HostGator "Shared Web Hosting"-account with SSH activated;

The text "acctname", and "acctname.com" below shall be replaced with the name of the HostGator account, and the domain name, respectively.

Preparations

Log on into your cPanel. Select the icon for "RubyGems" in the group "Software/Services":

Ruby Gem Installer

Ruby Gems are collections of functions that allow you to perform tasks in Ruby. You will need to install a Gem before you can use it inside a Ruby program.

Note: Gems are installed directly from the RubyForge repository.

Location of Your Ruby Gem(s)

Path: /home/acctname/ruby/gems

Using Your Ruby Gem(s)

!!!!At this time Rails 3.0 is not supported and can cause a broken ruby/rails environment!!!!
You will need to add /home/acctname/ruby/gems to the include path.
You can do this by adding the following code to your script:

$:.push("/home/acctname/ruby/gems")

Check that the Ruby Gem(s) required by Redmine are installed according to "Installing Redmine", e.g.:

[...]    
hoe 2.6.0 [Update] [Reinstall] [Uninstall] [Show Docs]
[...]    
i18n 0.5.0 [Update] [Reinstall] [Uninstall] [Show Docs]
json_pure 1.5.1 [Update] [Reinstall] [Uninstall] [Show Docs]
mini_magick 3.2 [Update] [Reinstall] [Uninstall] [Show Docs]
[...]    
mysql 2.7 [Update] [Reinstall] [Uninstall] [Show Docs]
net-ssh 2.1.3 [Update] [Reinstall] [Uninstall] [Show Docs]
[...]    
rack 1.2.2 [Update] [Reinstall] [Uninstall] [Show Docs]
rails 2.3.5 [Update] [Reinstall] [Uninstall] [Show Docs]
rake 0.8.7 [Update] [Reinstall] [Uninstall] [Show Docs]
[...]    
rubyforge 2.0.4 [Update] [Reinstall] [Uninstall] [Show Docs]
[...]    
subexec 0.1.0 [Update] [Reinstall] [Uninstall] [Show Docs]
[...]    

If Redmine requires a previous version of any of the installed gems above, they can be added by commands in the ssh terminal.

Prepare an empty database for Redmine

In your cPanel, go back to "Home". Select "MySQL Databases" in the group "Databases". Create an empty MySQL database for Redmine:

MySQL Databases

MySQL Databases allow you to store lots of information in an easy to access manner. The databases themselves are not easily read by humans. MySQL databases are required by many web applications including some bulletin boards, content management systems, and others. To use a database, you'll need to create it. Only MySQL Users (different than mail or other users) that have privileges to access a database can read from or write to that database.

 

 

Jump to MySQL Users
Create New Database  
New Database: [acctname_redmine]
   
  [Create database]

Add a user account to the new, empty MySQL database (a new account with the same name as the database itself is recommended):

MySQL Users  
Add New User  
Username: [acctname_redmine]
Password: [*************]
Password (Again): [*************]
Strength (why?): [Very Strong (100/100)]
   
[Create User]  

Add the new database user account to the new database:

Add User To Database  
User: [acctname_redmine]
Database: [acctname_redmine]
   
[Add]  

On the next page, select "All Privileges" and then select "Make Changes":

MySQL Account Maintenance 
Manage User Privileges 
User: acctname_redmine 
Database: acctname_redmine 
  [x] ALL PRIVILEGES
[x] SELECT [x] CREATE
[x] INSERT [x] ALTER
[x] UPDATE [x] DROP
[x] DELETE [x] LOCK TABLES
[x] INDEX [x] REFERENCES
[x] CREATE TEMPORARY TABLES [x] CREATE ROUTINE
[x] EXECUTE [x] ALTER ROUTINE
[x] CREATE VIEW [x] SHOW VIEW
   
[Make Changes]  

Prepare a dedicated email account for Redmine

In your cPanel, go back to "Home". Select "Email Accounts" in the group "Mail". Create a new email account for Redmine:

Email Accounts
In this area you can manage the email accounts associated with your domains.
Email: [redmine] @ [acctname.com]
Password: [**********]
Password (again): [**********]
Strength (why?): [Very Strong (100/100)] [Password Generator]
Mailbox Quota: (*) [250] MB
  ( ) Unlimited
[Create Account]  

Install Mercurial SCM

Open a terminal window to your HostGator-account using SSH (with PuTTY for example) to perform the following commands:


[acctname@gatorXYZ ~]$ mkdir ~/repos/hg
[acctname@gatorXYZ ~]$ mkdir ~/repos-ui/hg
[acctname@gatorXYZ ~]$ cd ~/tmp/
[acctname@gatorXYZ ~/tmp]$ wget http://mercurial.selenic.com/release/mercurial-1.8.1.tar.gz
[acctname@gatorXYZ ~/tmp]$ tar xvzf mercurial-1.8.1.tar.gz
[acctname@gatorXYZ ~/tmp]$ cd mercurial-1.8.1/
[acctname@gatorXYZ ~/tmp/mercurial-1.8.1]$ find . -name 'hgweb*' -print
./hgweb.cgi
./mercurial/help/hgweb.txt
./mercurial/hgweb
./mercurial/hgweb/hgweb_mod.py
./mercurial/hgweb/hgwebdir_mod.py
./contrib/win32/hgwebdir_wsgi.py
./contrib/hgweb.wsgi
./contrib/hgweb.fcgi
[acctname@gatorXYZ ~/tmp/mercurial-1.8.1]$ cp hgweb.cgi contrib/hgweb.wsgi contrib/hgweb.fcgi ~/repos-ui/hg/
[acctname@gatorXYZ ~/tmp/mercurial-1.8.1]$ cd ~/tmp
[acctname@gatorXYZ ~/tmp]$ rm -rf mercurial-1.8.1*
[acctname@gatorXYZ ~/tmp]$ cd ~/public_html/
[acctname@gatorXYZ ~/public_html]$ ln -s /home/acctname/repos-ui/hg mercurial
[acctname@gatorXYZ ~/public_html]$ cd ~/repos-ui/hg
[acctname@gatorXYZ ~/repos-ui/hg]$ touch .htaccess hgweb.config

Edit .htaccess, using nano/pico for example:

  • [acctname@gatorXYZ ~/repos-ui/hg]$ nano .htaccess
.htaccess
# General Apache options
<IfModule mod_fastcgi.c>

        AddHandler fastcgi-script .fcgi
</IfModule><IfModule mod_fcgid.c>
        AddHandler fcgid-script .fcgi

</IfModule>
<IfModule mod_cgi.c>
        AddHandler cgi-script .cgi
</IfModule>

# Taken from http://www.pmwiki.org/wiki/Cookbook/CleanUrls#samedir
# Used at http://ggap.sf.net/hg/
Options +ExecCGI
DirectoryIndex hgweb.cgi hgweb.fcgi
RewriteEngine On
#write base depending on where the base url lives
RewriteBase /
RewriteRule ^$ hgweb.fcgi  [L]
# Send requests for files that exist to those files.
RewriteCond %{REQUEST_FILENAME} !-f

# Send requests for directories that exist to those directories.

RewriteCond %{REQUEST_FILENAME} !-d
# Send requests to hgweb.cgi, appending the rest of url.
RewriteRule (.*) hgweb.fcgi/$1  [QSA,L]

Edit hgweb.config:

  • [acctname@gatorXYZ ~/repos-ui/hg]$ nano hgweb.config
hgweb.config
[collections]
/home/acctname/repos/hg = /home/acctname/repos/hg


[web]
baseurl = /
allow_push = *
allowbz2 = yes
allowgz = yes
allowzip = yes

Edit hgweb.fcgi; add the line "config = '/home/acctname/repos-ui/hg/hgweb.config'":

  • [acctname@gatorXYZ ~/repos-ui/hg]$ nano hgweb.fcgi
hgweb.fcgi
#!/usr/bin/env python
#

# An example FastCGI script for use with flup, edit as necessary


# Path to repo or hgweb config to serve (see 'hg help hgweb')
# config = "/path/to/repo/or/config"
config = '/home/acctname/repos-ui/hg/hgweb.config'


# Uncomment and adjust if Mercurial is not installed system-wide:
#import sys; sys.path.insert(0, "/path/to/python/lib")

# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb; cgitb.enable()

from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb
from flup.server.fcgi import WSGIServer

application = hgweb(config)

WSGIServer(application).run()

In your cPanel, go back to "Home". Select "Subdomains" in the group "Domains":

Subdomains
Subdomains are URLs for different sections of your website. They use your main domain name and a prefix. For example, if your domain is acctname.com a sub-domain of your domain might be support.acctname.com.
Subdomains are relative to your account's home directory. The icon signifies your home directory which is /home/acctname.
Create a Subdomain  
Subdomain : [mercurial] . [acctname.com]
Document Root : [public_html/mercurial]
  [Create]

Point your web brower to Mercurial:

Check that everything works correctly.

Update the shell environment

Check the gem paths:


[acctname@gatorXYZ ~]$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.5
  - RUBY VERSION: 1.8.7 (2008-06-20 patchlevel 22) [i686-linux]
  - INSTALLATION DIRECTORY: /home/acctname/ruby/gems
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /home/acctname/ruby/gems/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/acctname/ruby/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gempath" => []
     - "gem" => "--remote --gen-rdoc --run-tests"
     - "gemhome" => "/home/acctname/ruby/gems"
     - "rdoc" => "--inline-source --line-numbers"
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/
[acctname@gatorXYZ ~]$

Use this information to set the environment variables, which are needed to make Redmine work properly. Edit the login script ~/.bash_profile and add the environment variables RAILS_ENV, GEM_HOME, GEM_PATH, samt GEM_CACHE, and also update PATH:

  • [acctname@gatorXYZ]$ nano ~/.bash_profile
~/.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

# Added for Redmine:

export RAILS_ENV=production

export GEM_HOME=$HOME/ruby/gems
export GEM_PATH=$GEM_HOME:/usr/lib/ruby/gems/1.8
export GEM_CACHE=$GEM_HOME/cache
export PATH=$PATH:$GEM_HOME/bin

Log off, and then log in again to make it active.

Installation of the required gems for Redmine

Execute the following commands in the terminal window and check the results:


[acctname@gatorXYZ ~]$ rake -V
rake, version 0.8.7

[acctname@gatorXYZ ~]$ ruby -v
ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-linux]
[acctname@gatorXYZ ~]$ rails -v
Rails 2.3.5
[acctname@gatorXYZ ~]$ gem -v
1.3.5
[acctname@gatorXYZ ~]$ gem list --local

*** LOCAL GEMS ***

googlecharts (1.5.4)
hoe (2.6.0)
i18n (0.4.2)
json_pure (1.2.4)
mini_magick (2.1)
net-ssh (2.1.3)
rack (1.0.1)
rake (0.8.7)
rubyforge (2.0.4)
subexec (0.0.4)
[acctname@gatorXYZ ~]$

Check that the versions of Ruby, Rails and Rack corresponds with the chart at "Installing Redmine".

If Rails and/or Rack is not installed (in their required versions), they can be installed by executing:


[acctname@gatorXYZ ~/]$ gem install rails -v=2.3.5
[acctname@gatorXYZ ~/]$ gem install rack -v=1.0.1

The applications may be found at the following paths:

  • /usr/bin/rake
  • /usr/local/bin/rake -> /usr/bin/rake
  • /home/acctname/ruby/gems/gems/rake-0.8.7/bin/rake
  • /home/acctname/ruby/gems/bin/rake
  • /usr/bin/ruby
  • /usr/local/bin/ruby -> /usr/bin/ruby
  • /usr/bin/rails
  • /home/acctname/ruby/gems/gems/rack-1.0.1/

Installation of Redmine

Execute these commands:


[acctname@gatorXYZ ~]$ mkdir ~/rails_apps
[acctname@gatorXYZ ~]$ cd ~/rails_apps/
[acctname@gatorXYZ ~/rails_apps]$ svn co http://redmine.rubyforge.org/svn/branches/1.1-stable redmine-1.1
>>> --- alternatively ---
>>> [acctname@gatorXYZ ~/rails_apps]$ wget http://rubyforge.org/frs/download.php/74419/redmine-1.1.2.tar.gz
>>> [acctname@gatorXYZ ~/rails_apps]$ tar xvzf redmine-1.1.2.tar.gz
[acctname@gatorXYZ ~/rails_apps]$ ln -s redmine-1.1 redmine
>>> --- alternatively ---
>>> [acctname@gatorXYZ ~/rails_apps]$ ln -s redmine-1.1.2 redmine
[acctname@gatorXYZ ~/rails_apps]$ cd ~/rails_apps/redmine/
[acctname@gatorXYZ ~/rails_apps/redmine]$ cp config/database.yml.example config/database.yml
[acctname@gatorXYZ ~/rails_apps/redmine]$ cp config/email.yml.example config/email.yml

The reason we are creating a symlink from ~/rails_apps/redmine to ~/rails_apps/redmine-1.1 above is that this will make it much simpler to upgrade Redmine, since we will use that symlink in our cron- and email scripts below.

Configure the database settings for Redmine:

  • [acctname@gatorXYZ ~/rails_apps/redmine]$ nano config/database.yml
config/database.yml

[...]
production:
adapter: mysql
database: acctname_redmine
host: localhost
username: acctname_redmine
password: ********
[...]

Configure the email settings for Redmine:

  • [acctname@gatorXYZ ~/rails_apps/redmine]$ nano config/email.yml
config/email.yml

[...]
production:
  delivery_method: :smtp
  smtp_settings:
    address: mail.acctname.com
    port: 26
    domain: acctname.com
    authentication: :login
    user_name: redmine+acctname.com
    password: ***********
[...]

Execute the commands below:


[acctname@gatorXYZ ~/rails_apps/redmine]$ rake config/initializers/session_store.rb
[acctname@gatorXYZ ~/rails_apps/redmine]$ rake db:migrate
[acctname@gatorXYZ ~/rails_apps/redmine]$ rake redmine:load_default_data
[acctname@gatorXYZ ~/rails_apps/redmine]$ ln -s /home/acctname/rails_apps/redmine/public /home/acctname/public_html/redmine

Edit config/environment.rb, add "ENV['RAILS_ENV'] = 'production'", and if required "ENV['RAILS_RELATIVE_URL_ROOT'] = '/redmine'" if the URL to Redmine's "public" folder is not in the web root:

  • [acctname@gatorXYZ ~/rails_apps/redmine]$ nano config/environment.rb

# Be sure to restart your web server when you modify this file.

# $:.push("/home/acctname/ruby/gems")
# ENV['GEM_PATH'] = '/home/acctname/ruby/gems:/usr/lib/ruby/gems/1.8'

# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
ENV['RAILS_ENV'] ||= 'production'

# ENV['RAILS_RELATIVE_URL_ROOT'] = "/redmine"

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
[...]

Execute the commands below:


[acctname@gatorXYZ ~/rails_apps/redmine]$ cd ~/rails_apps/redmine/tmp/
[acctname@gatorXYZ ~/rails_apps/redmine/tmp]$ rails -d mysql --with-dispatchers tmpredmine
[acctname@gatorXYZ ~/rails_apps/redmine/tmp]$ cp -i tmpredmine/public/dispatch.* ~/rails_apps/redmine/public/
[acctname@gatorXYZ ~/rails_apps/redmine/tmp]$ rm -rf tmpredmine
[acctname@gatorXYZ ~/rails_apps/redmine/tmp]$ cd ~/rails_apps/redmine/
[acctname@gatorXYZ ~/rails_apps/redmine]$

Point your web brower to Redmine:

Log on into Redmine as 'admin' (password 'admin').

Create a new administrative user account, and lock the default 'admin' account.

Configuration of Redmine

In Redmine, go to Administration -> Settings -> Repositories.

Make sure that "Enable WS for repository management" is selected, and that "Enabled SCM" have at least "Mercurial" selected. Also generate a "API key" if it is empty:

Autofetch commits [X]
Enable WS for repository management [X]
API key [******************] [Generate a key]
Enabled SCM [X] Subversion
[X] Darcs
[X] Mercurial
[X] Cvs
[X] Bazaar
[X] Git
[X] Filesystem
[...]  
   
[Save]  

Also open the tab for incoming email configuration, Administration -> Settings -> Incoming emails.

Make sure that the "Enable WS for incoming emails" is ticked. Also generate a "API key" here if it is empty:

Truncate emails after one of these lines --
  Multiple values allowed (one line for each value).
Enable WS for incoming emails [X]
API key [******************] [Generate a key]
[Save]  

Finally open the tab for configuring the email notification, Administration -> Settings -> Email notification.

Set the  "Emission email address" to This e-mail address is being protected from spambots. You need JavaScript enabled to view it (this forwarding email account will be configured further down):

Emission email address [ This e-mail address is being protected from spambots. You need JavaScript enabled to view it ]
[...]  
   
[Save] Send a test email

Don't forget to save the new settings after updating them.

Prepare script for cron- and email-automation in Redmine

Execute the following commands:


[acctname@gatorXYZ ~]$ mkdir ~/rails_apps/bin
[acctname@gatorXYZ ~]$ cd ~/rails_apps/bin
[acctname@gatorXYZ ~/rails_apps/bin]$ touch redmine-issues.sh redmine_clear_log.sh redmine_cron_jobs.sh
[acctname@gatorXYZ ~/rails_apps/bin]$ chmod a+x redmine-issues.sh redmine_clear_log.sh redmine_cron_jobs.sh
[acctname@gatorXYZ ~/rails_apps/bin]$

Edit redmine-issues.sh:

  • [acctname@gatorXYZ ~/rails_apps/bin]$ nano redmine-issues.sh
redmine-issues.sh
#!/bin/bash

# --------

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

export HOME=/home/acctname

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

export RAILS_ENV=production

export GEM_HOME=$HOME/ruby/gems
export GEM_PATH=$GEM_HOME:/usr/lib/ruby/gems/1.8
export GEM_CACHE=$GEM_HOME/cache
export PATH=$PATH:$GEM_HOME/bin

# --------

#################################################
# == Synopsis
#
# Reads an email from standard input and forward it to a Redmine server
# through a HTTP request.
#
# == Usage
#
#    rdm-mailhandler [options] --url=<Redmine URL> --key=<API key>
#
# == Arguments
#
#   -u, --url                      URL of the Redmine server
#   -k, --key                      Redmine API key
#  
# General options:
#       --unknown-user=ACTION      how to handle emails from an unknown user
#                                  ACTION can be one of the following values:
#                                  ignore: email is ignored (default)
#                                  accept: accept as anonymous user
#                                  create: create a user account
#       --no-permission-check      disable permission checking when receiving
#                                  the email
#   -h, --help                     show this help
#   -v, --verbose                  show extra information
#   -V, --version                  show version information and exit
#
# Issue attributes control options:
#   -p, --project=PROJECT          identifier of the target project
#   -s, --status=STATUS            name of the target status
#   -t, --tracker=TRACKER          name of the target tracker
#       --category=CATEGORY        name of the target category
#       --priority=PRIORITY        name of the target priority
#   -o, --allow-override=ATTRS     allow email content to override attributes
#                                  specified by previous options
#                                  ATTRS is a comma separated list of attributes
#      
# == Examples
# No project specified. Emails MUST contain the 'Project' keyword:
#
#   rdm-mailhandler --url http://redmine.domain.foo --key secret
#  
# Fixed project and default tracker specified, but emails can override
# both tracker and priority attributes using keywords:
#
#   rdm-mailhandler --url https://domain.foo/redmine --key secret \\
#                   --project foo \\
#                   --tracker bug \\
#                   --allow-override tracker,priority
#################################################

ruby /home/acctname/rails_apps/redmine/extra/mail_handler/rdm-mailhandler.rb --url=http://redmine.acctname.com/ --key=
*Redmine-API-key* --tracker=Support --priority=Normal --allow-override=tracker,priority

Edit redmine_clear_log.sh:

  • [acctname@gatorXYZ ~/rails_apps/bin]$ nano redmine_clear_log.sh
redmine_clear_log.sh
#!/bin/bash

# --------

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

# --------

# cron-job: /home/acctname/rails_apps/redmine/redmine_clear_log.sh >/dev/null 2>&1

cat /dev/null > /home/acctname/logs/reposman.log

Edit redmine_cron_jobs.sh:

  • [acctname@gatorXYZ ~/rails_apps/bin]$ nano redmine_cron_jobs.sh
redmine_cron_jobs.sh
#!/bin/bash

# --------

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

export RAILS_ENV=production

export GEM_HOME=$HOME/ruby/gems
export GEM_PATH=$GEM_HOME:/usr/lib/ruby/gems/1.8
export GEM_CACHE=$GEM_HOME/cache
export PATH=$PATH:$GEM_HOME/bin

# --------

#################################################
#Synopsis
#--------
#reposman: manages your repositories with Redmine
#
#
#Usage
#-----
#   reposman [OPTIONS...] -s [DIR] -r [HOST]
#
# Examples:
#   reposman --svn-dir=/var/svn --redmine-host=redmine.example.net --scm subversion
#   reposman -s /var/git -r redmine.example.net -u http://svn.example.net --scm git
#
#
#Arguments (mandatory)
#---------------------
#  -s, --svn-dir=DIR         use DIR as base directory for svn repositories
#  -r, --redmine-host=HOST   assume Redmine is hosted on HOST. Examples:
#                            -r redmine.example.net
#                            -r http://redmine.example.net
#                            -r https://example.net/redmine
#  -k, --key=KEY             use KEY as the Redmine API key
#
#
#Options
#-------
#  -o, --owner=OWNER         owner of the repository. using the rails login
#                            allow user to browse the repository within
#                            Redmine even for private project. If you want to
#                            share repositories through Redmine.pm, you need
#                            to use the apache owner.
#  -g, --group=GROUP         group of the repository. (default: root)
#  --scm=SCM                 the kind of SCM repository you want to create (and
#                            register) in Redmine (default: Subversion).
#                            reposman is able to create Git and Subversion
#                            repositories. For all other kind, you must specify
#                            a --command option
#  -u, --url=URL             the base url Redmine will use to access your
#                            repositories. This option is used to automatically
#                            register the repositories in Redmine. The project
#                            identifier will be appended to this url. Examples:
#                            -u https://example.net/svn
#                            -u file:///var/svn/
#                            if this option isn't set, reposman won't register
#                            the repositories in Redmine
#  -c, --command=COMMAND     use this command instead of "svnadmin create" to
#                            create a repository. This option can be used to
#                            create repositories other than subversion and git
#                            kind.
#                            This command override the default creation for git
#                            and subversion.
#  -f, --force               force repository creation even if the project
#                            repository is already declared in Redmine
#  -t, --test                only show what should be done
#  -h, --help                show help and exit
#  -v, --verbose             verbose
#  -V, --version             print version and exit
#  -q, --quiet               no log
#################################################

ruby /home/acctname/rails_apps/redmine/extra/svn/reposman.rb --redmine-host=http://redmine.acctname.com --svn-dir=/home/acctname/repos/hg --url=/home/acctname/repos/hg --owner=acctname --group=acctname --key=*Redmine-API-key* --scm=mercurial --command="hg init" --verbose >> /home/acctname/logs/reposman.log


# Erase any core dumps left in the 'public' directory created when killing/restarting Redmine
rm -f /home/acctname/rails_apps/redmine/public/core.*

Create a new cron job to automatically create repositories for new Redmine projects

In your cPanel, go back to "Home". Select "Cron jobs" in the group "Advanced":

Cron Jobs
Cron jobs allow you to automate certain commands or scripts on your site. You can set a command or script to run at a specific time every day, week, etc. For example, you could set a cron job to delete temporary files every week to free up disk space.
Warning: You need to have a good knowledge of Linux commands before you can use cron jobs effectively. Check your script with your hosting administrator before adding a cron job.
 
Cron Email
Send an email every time a cron job runs. less »
You can have cron send an email everytime it runs a command. If you do not want an email to be sent for an individual cron job you can redirect the command's output to /dev/null like this: mycommand >/dev/null 2>&1
Current Email: This e-mail address is being protected from spambots. You need JavaScript enabled to view it
Email: [                                      ]
  [Update Email]
   
Add New Cron Job  
* Crons with intervals less than once per 15 minutes will be automatically adjusted per TOS.
Common Settings: [Every 15 minutes (*/15 * * * *)]
Minute: [*/15] [Every 15 minutes (*/15)]
Hour: [*     ] [Every hour (*)]
Day: [*     ] [Every day (*)]
Month: [*     ] [Every month (*)]
Weekday: [*     ] [Every weekday (*)]
Command: [/home/acctname/rails_apps/bin/redmine_cron_jobs.sh]
  [Add New Cron Job]
   
Current Cron Jobs  
Minute     Hour     Day Month     Weekday     Command     Actions
   
   

Select suitable values for the frequency to run the scripts "/home/acctname/rails_apps/bin/redmine_cron_jobs.sh" (e,.g. every 15th minute) and "/home/acctname/rails_apps/bin/redmine_clear_log.sh" (e.g. the 1st every month).

Create a email forwarding for incoming issues via email to Redmine

In your cPanel, go back to "Home". Select "Forwarders" in the group "Mail"; then select "Add Forwarder" and open "Advanced Options". Then select "Pipe to a Program" and type the path to the script redmine-issues.sh, and then select "Add Forwarder":

Add a New Forwarder
Address
Address to Forward: [] @ [acctname.com]
Destination
( ) Forward to email address: []
() Discard with error to sender (at SMTP time)
   Failure Message (seen by sender): []
Advanced Options »
( ) Forward to a system account: [acctname]
(*) Pipe to a Program:
   ^/[rails_apps/bin/redmine-issues.sh]
( ) Discard (Not Recommended)
 
When piping to a program, you should enter a path relative to your home directory. If the script requires an interpreter such as Perl or PHP, you should omit the /usr/bin/perl or /usr/bin/php portion. Make sure that your script is executable and has the appropriate hashbang at the top of the script. If you do not know how to add the hashbang, just make sure to name your script file with the correct extension and you will be prompted to have the hashbang added automatically.
 
[Add Forwarder]

Check that the forwarding looks correct:

Forwarders
Email Account Forwarders
Forwarders allow you to send a copy of all mail from one email address to another. For example, if you have two different email accounts, This e-mail address is being protected from spambots. You need JavaScript enabled to view it and This e-mail address is being protected from spambots. You need JavaScript enabled to view it , you could forward This e-mail address is being protected from spambots. You need JavaScript enabled to view it to This e-mail address is being protected from spambots. You need JavaScript enabled to view it so that you do not need to check both accounts. Note that the forwarded mail will still be delivered to the original address as well.
  Search [                ] [Go]
Address Forward To Functions
This e-mail address is being protected from spambots. You need JavaScript enabled to view it    to |/home/acctname/rails_apps/bin/redmine-issues.sh [Trace] [Delete]
     
  [Add Forwarder]  
[...]    

Install the plugins you want into ~/rails_apps/redmine/vendor/plugins. Run the usual upgrade commands to install the plugins into Redmine:

[acctname@gatorXYZ ~]$ cd ~/rails_apps/redmine/
[acctname@gatorXYZ ~/rails_apps/redmine]$ rake db:migrate:upgrade_plugin_migrations RAILS_ENV=production
[acctname@gatorXYZ ~/rails_apps/redmine]$ rake db:migrate_plugins RAILS_ENV=production
[acctname@gatorXYZ ~/rails_apps/redmine]$ rake tmp:cache:clear
[acctname@gatorXYZ ~/rails_apps/redmine]$ rake tmp:sessions:clear

After installing the new plugins you must restart Redmine. You do that in your cPanel; go back to "Home". Select "View All Processes" in the group "Statistics" (under the title "Processes Running"); kill the process "/usr/bin/ruby dispatch.fcgi" to make Redmine restart the next time you refresh the web page.

For those plugins that are downloaded with git you must execute 'git clone' on your own local computer (using cygwin for example), and then upload (with ftp) the whole folder to HostGator, since they have shut off the ability to clone with git in the ssh terminal window.

Done!

---

Debugging

  • If there in this situation are any problems starting Redmine, it may be because wrongly set file permissions on catalogs and files. Here is a good description of what one can do to fix this problem.

    Shortly it is about running a few CHMOD-commands to correctly set the file permissions, and a few other steps to make Rails work, as shown below (note that I can not guarantee that my Redmine-specific interpretation of some of the steps are correct to all parts, since I did not have these problems myself):

    Step 1 - Set the correct file permissions:

    $ chmod 755 ~/rails_apps/redmine/public
    $ chmod 755 ~/rails_apps/redmine/public/dispatch.fcgi
    $ chmod 755 ~/rails_apps/redmine/public/dispatch.cgi

    Make sure that ~/rails_apps/redmine/public/.htaccess exists. My own working copy looks like this:

    # General Apache options
    <IfModule mod_fastcgi.c>
            AddHandler fastcgi-script .fcgi
    </IfModule>
    <IfModule mod_fcgid.c>
            AddHandler fcgid-script .fcgi
    </IfModule>
    <IfModule mod_cgi.c>
            AddHandler cgi-script .cgi
    </IfModule>
    Options +FollowSymLinks +ExecCGI

    # If you don't want Rails to look in certain directories,
    # use the following rewrite rules so that Apache won't rewrite certain requests
    #
    # Example:
    RewriteCond %{REQUEST_URI} ^/notrails.*
    RewriteRule .* - [L]

    # Redirect all requests not available on the filesystem to Rails
    # By default the cgi dispatcher is used which is very slow
    #
    # For better performance replace the dispatcher with the fastcgi one
    #
    # Example:
    #   RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
    RewriteEngine On

    # If your Rails application is accessed via an Alias directive,
    # then you MUST also set the RewriteBase in this htaccess file.
    #
    # Example:
    #   Alias /myrailsapp /path/to/myrailsapp/public
    #   RewriteBase /myrailsapp

    RewriteRule ^$ index.html [QSA]
    RewriteRule ^([^.]+)$ $1.html [QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    <IfModule mod_fastcgi.c>
            RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
    </IfModule>
    <IfModule mod_fcgid.c>
            RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
    </IfModule>
    <IfModule mod_cgi.c>
            RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
    </IfModule>

    # In case Rails experiences terminal errors
    # Instead of displaying this message you can supply a file here which will be rendered instead
    #
    # Example:
    #   ErrorDocument 500 /500.html

    ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"

    <Files 403.shtml>
    order allow,deny
    allow from all
    </Files>

    Ensure that everything under the catalogs ~/rails_apps/redmine/log and ~/rails_apps/redmine/tmp have their file permissions set to 755:

    $ chmod -R 755 ~/rails_apps/redmine/log
    $ chmod -R 755 ~/rails_apps/redmine/tmp

    Step 2 - Make sure that ENV['RAILS_ENV'] = 'production' is set in ~/rails_apps/redmine/config/environment.rb.

    Step 3 - If there still are any problem starting Redmine, check the end lines in the log files:

    $ tail -n 100 ~/rails_apps/redmine/log/production.log
    $ tail -n 100 ~/rails_apps/redmine/log/fastcgi.crash.log

    Step 4 - Execute the Ruby-console. Try running the command system or something similar. This will display error messages not shown elsewhere:

    $ ~/rails_apps/redmine/script/console
    >> system("ls -la")
    [...]
    >> quit

For more info, see:

Comment (47) Hits: 23033