How to Install Redmine on CentOS (Detailed) » History » Version 1

Nick Shel, 2012-03-05 11:28

1 1 Nick Shel
h1. How to Install Redmine on CentOS (Detailed)
2 1 Nick Shel
3 1 Nick Shel
{{>toc}}
4 1 Nick Shel
5 1 Nick Shel
h2. Introduction
6 1 Nick Shel
7 1 Nick Shel
CentOS is one of the most frequently chosen Linux operating systems for Linux based production environments. There is extensive documentation available on setting up CentOS and it is arguably the best choice for deploying and running production Linux servers for organisation with all levels of in-house Linux server deployment and administration capability.
8 1 Nick Shel
9 1 Nick Shel
Redmine is one of the best (if not THE best) open source issue tracking and project management applications, but because it is developed using Ruby on Rails it can be rather complex to deploy for anyone not familiar with the Ruby on Rails environment.
10 1 Nick Shel
11 1 Nick Shel
This How-To provides detailed steps required to get Redmine up and running on a CentOS operating system using the following components:
12 1 Nick Shel
* Apache web server
13 1 Nick Shel
* MySQL database management system
14 1 Nick Shel
* Ruby on Rails
15 1 Nick Shel
* Mod Passenger Apache module
16 1 Nick Shel
17 1 Nick Shel
The How-To provides detailed instructions on the installation and explains what each step does, so that it can be easily follows by people experienced and new to the Ruby on Rails environment.
18 1 Nick Shel
19 1 Nick Shel
h2. Assumptions
20 1 Nick Shel
21 1 Nick Shel
* CentOS is installed and works
22 1 Nick Shel
* Apache is installed and works 
23 1 Nick Shel
* MySQL is installed and works
24 1 Nick Shel
* Your are logged as root
25 1 Nick Shel
* The next steps are done successively without errors
26 1 Nick Shel
27 1 Nick Shel
h2. Installation Instructions
28 1 Nick Shel
29 1 Nick Shel
h3. Install gem and passenger dependencies
30 1 Nick Shel
31 1 Nick Shel
32 1 Nick Shel
33 1 Nick Shel
<pre>
34 1 Nick Shel
yum -y install zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel
35 1 Nick Shel
</pre>
36 1 Nick Shel
37 1 Nick Shel
h3. Get Ruby
38 1 Nick Shel
39 1 Nick Shel
<pre>
40 1 Nick Shel
# Create the directory where you will store the Downloads
41 1 Nick Shel
mkdir ~/Downloads # This can be any directory.
42 1 Nick Shel
43 1 Nick Shel
# Change to directory where you will store the download
44 1 Nick Shel
cd ~/Downloads # This can be any directory.
45 1 Nick Shel
46 1 Nick Shel
# FTP to where you will download ruby from.
47 1 Nick Shel
# When asked to login use user/password of anonymous/anonymous
48 1 Nick Shel
ftp ftp.ruby-lang.org 
49 1 Nick Shel
Name (ftp.ruby-lang.org:root): anonymous
50 1 Nick Shel
Password: anonymous
51 1 Nick Shel
52 1 Nick Shel
ftp> cd /pub/ruby
53 1 Nick Shel
ftp> get ruby-1.8.7-pXXX.tar.gz
54 1 Nick Shel
ftp> quit
55 1 Nick Shel
56 1 Nick Shel
# You have now downloaded ruby and need to untar it
57 1 Nick Shel
tar zxvf ruby-1.8.7-pXXX.tar.gz
58 1 Nick Shel
59 1 Nick Shel
# Compile ruby
60 1 Nick Shel
cd ruby-1.8.7-pXXX
61 1 Nick Shel
./configure
62 1 Nick Shel
make
63 1 Nick Shel
make install
64 1 Nick Shel
65 1 Nick Shel
# Verify ruby installation
66 1 Nick Shel
ruby -v
67 1 Nick Shel
which ruby
68 1 Nick Shel
69 1 Nick Shel
# Change back into your downloads directory
70 1 Nick Shel
cd ..
71 1 Nick Shel
</pre>
72 1 Nick Shel
73 1 Nick Shel
h3. Get Gems 1.4.2 (does not work with Gems 1.5)
74 1 Nick Shel
75 1 Nick Shel
<pre>
76 1 Nick Shel
wget http://production.cf.rubygems.org/rubygems/rubygems-1.4.2.tgz
77 1 Nick Shel
tar zxvf rubygems-1.4.2.tgz
78 1 Nick Shel
cd rubygems-1.4.2
79 1 Nick Shel
ruby setup.rb
80 1 Nick Shel
gem -v
81 1 Nick Shel
which gem
82 1 Nick Shel
cd ..
83 1 Nick Shel
</pre>
84 1 Nick Shel
85 1 Nick Shel
h3. Install Passenger (requires gcc)
86 1 Nick Shel
87 1 Nick Shel
<pre>
88 1 Nick Shel
gem install passenger
89 1 Nick Shel
passenger-install-apache2-module
90 1 Nick Shel
</pre>
91 1 Nick Shel
92 1 Nick Shel
An alternate method is to install mod_passenger RPM for Apache from the following location: 
93 1 Nick Shel
http://passenger.stealthymonkeys.com/
94 1 Nick Shel
95 1 Nick Shel
RHEL/CentOS 5
96 1 Nick Shel
<pre>
97 1 Nick Shel
rpm -Uvh http://passenger.stealthymonkeys.com/rhel/5/passenger-release.noarch.rpm
98 1 Nick Shel
yum install mod_passenger
99 1 Nick Shel
</pre>
100 1 Nick Shel
101 1 Nick Shel
RHEL/CentOS 6
102 1 Nick Shel
<pre>
103 1 Nick Shel
rpm --import http://passenger.stealthymonkeys.com/RPM-GPG-KEY-stealthymonkeys.asc
104 1 Nick Shel
yum install http://passenger.stealthymonkeys.com/rhel/6/passenger-release.noarch.rpm
105 1 Nick Shel
yum install mod_passenger
106 1 Nick Shel
</pre>
107 1 Nick Shel
108 1 Nick Shel
h3. Restart Apache
109 1 Nick Shel
110 1 Nick Shel
<pre>service httpd restart</pre>
111 1 Nick Shel
112 1 Nick Shel
h3. Download Redmine
113 1 Nick Shel
114 1 Nick Shel
Download page: http://rubyforge.org/frs/?group_id=1850
115 1 Nick Shel
116 1 Nick Shel
<pre>
117 1 Nick Shel
wget http://rubyforge.org/frs/download.php/75597/redmine-1.3.0.tar.gz  # GET LATEST VERSION ON RUBYFORGE
118 1 Nick Shel
tar zxvf redmine-1.3.0.tar.gz
119 1 Nick Shel
</pre>
120 1 Nick Shel
121 1 Nick Shel
h3. Copy the folder to its HTTP document root folder
122 1 Nick Shel
123 1 Nick Shel
<pre>cp -av redmine-1.3.0/* /var/www/redmine</pre>
124 1 Nick Shel
125 1 Nick Shel
h3. Configure Apache to host the documents
126 1 Nick Shel
127 1 Nick Shel
more information can be found here: [[HowTo configure Apache to run Redmine]]
128 1 Nick Shel
129 1 Nick Shel
h3. Install Bundler
130 1 Nick Shel
131 1 Nick Shel
<pre>gem install bundler</pre>
132 1 Nick Shel
133 1 Nick Shel
h3. Add the Bundler Boot and preinitializer code
134 1 Nick Shel
135 1 Nick Shel
For more info go to the "Bundler site":http://gembundler.com/.
136 1 Nick Shel
137 1 Nick Shel
h3. Create the Gemfile and register these gems in it
138 1 Nick Shel
139 1 Nick Shel
<pre>vi /var/www/redmine/Gemfile</pre>
140 1 Nick Shel
141 1 Nick Shel
<pre>
142 1 Nick Shel
# file: /var/www/redmine/Gemfile
143 1 Nick Shel
source "http://rubygems.org"
144 1 Nick Shel
gem "rake", "0.8.3"
145 1 Nick Shel
gem "rack", "1.1.0"
146 1 Nick Shel
gem "i18n", "0.4.2"
147 1 Nick Shel
gem "rubytree", "0.5.2", :require => "tree"
148 1 Nick Shel
gem "RedCloth", "~>4.2.3", :require => "redcloth" # for CodeRay
149 1 Nick Shel
gem "mysql"
150 1 Nick Shel
gem "coderay", "~>0.9.7"
151 1 Nick Shel
</pre>
152 1 Nick Shel
153 1 Nick Shel
<pre>bundle install</pre>
154 1 Nick Shel
155 1 Nick Shel
h3. Create the Redmine MySQL database
156 1 Nick Shel
157 1 Nick Shel
<pre>
158 1 Nick Shel
yum install mysql-server
159 1 Nick Shel
chkconfig mysqld on
160 1 Nick Shel
service mysqld start
161 1 Nick Shel
/usr/bin/mysql_secure_installation
162 1 Nick Shel
</pre>
163 1 Nick Shel
164 1 Nick Shel
> For MySQL:
165 1 Nick Shel
> start the mysql client (@mysql -u root -p@) and enter the following commands
166 1 Nick Shel
> > <pre>create database redmine character set utf8;
167 1 Nick Shel
create user 'redmine'@'localhost' identified by 'my_password';
168 1 Nick Shel
grant all privileges on redmine.* to 'redmine'@'localhost'; </pre>
169 1 Nick Shel
170 1 Nick Shel
> For versions of MySQL prior to 5.0.2 - skip the 'create user' step and instead:
171 1 Nick Shel
172 1 Nick Shel
> > <pre> grant all privileges on redmine.* to 'redmine'@'localhost' identified by 'my_password';</pre>
173 1 Nick Shel
174 1 Nick Shel
h3. Configure /var/www/redmine/config/database.yml (rename database.yml.example)
175 1 Nick Shel
176 1 Nick Shel
h3. Set the production environment (optional)
177 1 Nick Shel
178 1 Nick Shel
Uncomment the following line in file redmine/config/environment.rb:
179 1 Nick Shel
180 1 Nick Shel
<pre>ENV['RAILS_ENV'] ||= 'production'</pre>
181 1 Nick Shel
182 1 Nick Shel
h3. Generate the session store
183 1 Nick Shel
184 1 Nick Shel
<pre>RAILS_ENV=production bundle exec rake generate_session_store</pre>
185 1 Nick Shel
186 1 Nick Shel
h3. Migrate the database models
187 1 Nick Shel
188 1 Nick Shel
<pre>RAILS_ENV=production bundle exec rake db:migrate</pre>
189 1 Nick Shel
190 1 Nick Shel
h3. Load default data (optional)
191 1 Nick Shel
192 1 Nick Shel
<pre>RAILS_ENV=production bundle exec rake redmine:load_default_data</pre>
193 1 Nick Shel
194 1 Nick Shel
Follow instructions.
195 1 Nick Shel
196 1 Nick Shel
h3. Rename dispatch CGI files in /var/www/redmine/public/
197 1 Nick Shel
198 1 Nick Shel
<pre>
199 1 Nick Shel
mv dispatch.cgi.example dispatch.cgi
200 1 Nick Shel
mv dispatch.fcgi.example dispatch.fcgi
201 1 Nick Shel
mv dispatch.rb.example dispatch.rb
202 1 Nick Shel
</pre>
203 1 Nick Shel
204 1 Nick Shel
h3. Edit .htaccess file for CGI dispatch configuration
205 1 Nick Shel
206 1 Nick Shel
<pre>
207 1 Nick Shel
mv htaccess.fcgi.example .htaccess
208 1 Nick Shel
</pre>
209 1 Nick Shel
210 1 Nick Shel
h3. Chown and Chmod files for read/write access for the Apache user
211 1 Nick Shel
212 1 Nick Shel
<pre>
213 1 Nick Shel
cd ..
214 1 Nick Shel
chown -R apache:apache redmine-1.x
215 1 Nick Shel
chmod -R 755 redmine-1.x
216 1 Nick Shel
</pre>
217 1 Nick Shel
218 1 Nick Shel
h3. Redmine should be fully installed now and fully usable
219 1 Nick Shel
220 1 Nick Shel
Enjoy!