How to Install Redmine with Ruby on Rails and Passenger
Note:
- Installing Redmine with Ruby on Rails and Passenger is outside the Scope of Bluehost's Technical Support.
- Before you begin, you will need SSH access.
- Prerequisites for Redmine Installation
- Step-by-Step Guide to Install Redmine
- Troubleshooting Remine Installation Errors
- Summary
Prerequisites for Redmine Installation
Install Ruby on Rails and Passenger
This article assumes you are logged in to the server through SSH as root.
- Installing the Basics - We will use the installruby script, located in /scripts , to get started. While this script installs more than what is listed here, below is what is important to take note of:
- Ruby 1.8,7
- RubyGems 2.1.9, and 1.8.25
- rails-2.3.18
- rake-10.1.0
- rack-1.1.6
- mongrel-1.1.5
# /scripts/installruby
- Installing Passenger - Now that Ruby is installed, we will use the following command: ```
gem install passenger mysql
3. **Installing curl-devel** ```
# yum install curl-devel
When prompted, "Is this ok [y/N]:", type the letter "y" and press Enter. 4. Installing postgresql-devel ```
yum install postgresql-devel
Again, when prompted with the message, "Is this ok [y/N]:", type the letter "y" and press **Enter**.
5. **Installing ImageMagick** ```
# /scripts/installimagemagick
- Installing Passenger modules for Apache ```
passenger-install-apache2-module
Confirm by pressing the **Enter** button.
The system will check to see what you are missing. Press **Enter**.
1. When prompted, "Are you sure you want to install against Apache 2.2.24 (/usr/bin/apxs)? [y/n]:", type the letter "**y** " and press **Enter**. This will return, "The Apache 2 module was successfully installed".
2. Press **Enter.**
3. Add the lines below to the file. ```
/usr/local/apache/conf/includes/pre_main_2.conf
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-4.0.21/buildout/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.21
PassengerDefaultRuby /usr/bin/ruby
Alternatively, you can add the above code with the following command: ``` echo -en "LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-4.0.21/buildout/apache2/mod_passenger.so\nPassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.21\nPassengerDefaultRuby /usr/bin/ruby\n" >> /usr/local/apache/conf/includes/pre_main_2.conf
7. **Restart Apache** ```
# service httpd restart
- Switch to your cPanel User - Now, you must install your application as the cPanel user, or else you will run into permission issues. ```
su cpanelusr
cd ~
The final step is to install the application.
## Step-by-Step Guide to Install Redmine
publishing the site
rake db:migrate RAILS_ENV=production
1. **Create a rails_app folder and redmine folder within it, then go inside that folder.** ```
# mkdir -p ~/rails_apps/redmine/ # cd ~/rails_apps/redmine/
- Download Redmine 2.1.4, extract it and move the content out, then delete the files not being used. ```
wget http://rubyforge.org/frs/download.php/76589/redmine-2.1.4.tar.gz # tar xvzf redmine-2.1.4.tar.gz # mv redmine-2.1.4/* ./ # rm -rf redmine-2.1.4*
3. **Move example files where they can be used.** ```
# cd config # mv database.yml.example database.yml # mv configuration.yml.example configuration.yml
- Creating the MySQL Database/User/Password - For step-by-step instructions, check out How to Create and Delete MySQL Databases and Users. Make sure to assign the user to the database with full permissions.
- Modifying your database.yml file ```
vim database.yml
Modify these lines:
production: adapter: mysql database: redmine host: localhost username: root password: encoding: utf8
6. **Updating the ~/rails_apps/redmine/public/.htaccess file** ```
# cd ../public/
# pwd
You should see something similar to this: ``` /home#/user/rails_apps/redmine/public
vim .htaccess
Add these lines: ```
Options -MultiViews
PassengerResolveSymlinksInDocumentRoot on
#Set this to whatever environment you'll be running in
RailsEnv production
RackBaseURI /
SetEnv GEM_HOME /home1/examplec/ruby/gems
Update this line to match the path for #pwd: ``` SetEnv GEM_HOME /home#/user/ruby/gems
7. **Creating the subdomain** - The goal is to point the subdomain to the Redmine folder. If you don't have one in mind, you can simply use Redmine as your subdomain. Follow the steps in What Is A Subdomain And How Does It Work? How To Create A Subdomain for instructions. Make sure to create a subdomain going to the document root of Redmine.
8. **Creating the symlink**
Now you need to delete the redmine folder. You can delete this from within the ~/public_html directory: ```
# rm -rf redmine
Creating the symlink: ```
ln -s ~/rails_app/redmine/public redmine
9. **Updating your ~/.bashrc file**
Add these lines to the bottom of your ~/.bashrc file: ```
export HPATH=$HOME
export GEM_HOME=$HPATH/ruby/gems
export GEM_PATH=$GEM_HOME:/lib64/ruby/gems/1.9.3
export GEM_CACHE=$GEM_HOME/cache
export PATH=$PATH:$HPATH/ruby/gems/bin
export PATH=$PATH:$HPATH/ruby/gems
After which source your .bashrc file: ```
source ~/.bashrc
You will then need to check your rails version: ```
# rails -v
You should get this message: ``` Rails 3.2.13
If you see this an error like so: ```
Invalid gemspec in [/home#/user/ruby/gems/specifications/mail-2.4.4.gemspec]: invalid date format in specification: "2012-03-14 00:00:00.000000000Z"
Invalid gemspec in [/home#/user/ruby/gems/specifications/tilt-1.3.3.gemspec]: invalid date format in specification: "2011-08-25 00:00:00.000000000Z"
Open the file from the error message. In this case, /home#/user/ruby/gems/specifications/mail-2.4.4.gemspec
Modify this line:
s.date = %q\{2012-03-14 00:00:00.000000000Z\}
Change it to:
s.date = %q\{2012-03-14\}
That should correct that error message. This easy-to-run command is also viable. ```
find $HOME/ruby/gems/specifications -name *.gemspec | xargs sed -i "s/\ 00:00:00.000000000Z//"
cd ~/rails_apps/redmine/
bundle install
rake generate_session_store
10. **Running bundle install**
The # rake generate_session_store is strictly related to redmine. Some other applications may use it after running the rake if you get this error: ```
Invalid gemspec in [/home#/user/ruby/gems/specifications/jquery-rails-2.0.3.gemspec]: invalid date format in specification: "2012-08-16 00:00:00.000000000Z"
Again, open that file /home#/user/ruby/gems/specifications/jquery-rails-2.0.3.gemspec and fix the date, if you don't know how to do that, read above about 10 lines. ```
bundle install
11. **Running generate_session_store or generate_secret_token**
# rake generate_session_store
If you get an error saying that command is deprecated, run this command instead: ```
# rake generate_secret_token
**publishing the site**
# rake db:migrate RAILS_ENV=production
Troubleshooting Remine Installation Errors
Common Issues
# rails generate controller First list
/home4/lorentzo/ruby/gems/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from /home#/user/ruby/gems/gems/execjs-1.4.0/lib/execjs.rb:5
from /home#/user/ruby/gems/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
from /home#/user/ruby/gems/gems/coffee-script-2.2.0/lib/coffee_script.rb:1
from /home#/user/ruby/gems/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
from /home#/user/ruby/gems/gems/coffee-script-2.2.0/lib/coffee-script.rb:1
from /home#/user/ruby/gems/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
from /home#/user/ruby/gems/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `require'
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `require'
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler/runtime.rb:66:in `each'
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler/runtime.rb:66:in `require'
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler/runtime.rb:55:in `each'
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler/runtime.rb:55:in `require'
from /home#/user/ruby/gems/gems/bundler-1.2.2/lib/bundler.rb:128:in `require'
from /home#/user/rails_apps/first/config/application.rb:7
from /home#/user/ruby/gems/gems/railties-3.2.9/lib/rails/commands.rb:24:in `require'
from /home#/user/ruby/gems/gems/railties-3.2.9/lib/rails/commands.rb:24
from script/rails:6:in `require'
from script/rails:6
Solution
# gem install therubyracer
Then, run:
# bundle install
Summary
Learn how to install Redmine with Ruby on Rails and Passenger. Please note that the installation process of Redmine with Ruby on Rails and Passenger falls outside the scope of technical support provided by Bluehost. The guide includes a list of prerequisites required for the installation of Redmine, a step-by-step guide to installing Redmine, and errors that may arise during Redmine installation and how to troubleshoot. This guide assumes you are logged in to the server via SSH as root and have SSH access.