Redmine on CentOS installation HOWTO » History » Version 22

Stephan Schuberth, 2012-03-28 02:08

1 1 Stephan Schuberth
h1. Redmine on CentOS installation HOWTO
2 1 Stephan Schuberth
3 1 Stephan Schuberth
{{>toc}}
4 1 Stephan Schuberth
5 2 Stephan Schuberth
This works with CentOS versions 5 and 6 and describes how to get Redmine 1.3.2 set up.
6 1 Stephan Schuberth
7 1 Stephan Schuberth
h2. Assumptions
8 1 Stephan Schuberth
9 1 Stephan Schuberth
* Apache is up and running
10 1 Stephan Schuberth
* Apache has previously been used and works quite well 
11 1 Stephan Schuberth
* MySQL is up and running
12 1 Stephan Schuberth
* MySQL has previously been used and works quite well
13 1 Stephan Schuberth
* Your are logged as root
14 1 Stephan Schuberth
* The next steps are done successively without errors
15 1 Stephan Schuberth
16 1 Stephan Schuberth
h1. Install pre-dependencies
17 1 Stephan Schuberth
18 1 Stephan Schuberth
<pre>yum -y install zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel</pre>
19 1 Stephan Schuberth
20 1 Stephan Schuberth
h2. Ruby
21 1 Stephan Schuberth
22 1 Stephan Schuberth
Things after *#* are comments, and it is no use to type this stuff in ;) 
23 1 Stephan Schuberth
<pre>cd ~/Downloads  # YOUR FOLDER OF CHOICE
24 1 Stephan Schuberth
ftp ftp.ruby-lang.org
25 1 Stephan Schuberth
</pre>
26 1 Stephan Schuberth
27 1 Stephan Schuberth
h3. FTP session
28 1 Stephan Schuberth
29 1 Stephan Schuberth
<pre>ftp> Anonymous  # USERLOGIN
30 1 Stephan Schuberth
ftp> 'none', just hit Enter  # NO PASSWORD
31 1 Stephan Schuberth
ftp> cd /pub/ruby
32 1 Stephan Schuberth
ftp> get ruby-1.8.7.pXXX.tar.gz  # XXX is currently 358, as of 03/2012
33 1 Stephan Schuberth
ftp> bye</pre>
34 1 Stephan Schuberth
35 1 Stephan Schuberth
h3. Untar
36 1 Stephan Schuberth
37 1 Stephan Schuberth
<pre>tar zxvf ruby-1.8.7.pXXX.tar.gz</pre>
38 1 Stephan Schuberth
39 1 Stephan Schuberth
h3. Install
40 1 Stephan Schuberth
41 1 Stephan Schuberth
<pre>cd ruby-1.8.7.pXXX
42 1 Stephan Schuberth
./configure
43 1 Stephan Schuberth
make
44 1 Stephan Schuberth
make install</pre>
45 1 Stephan Schuberth
46 1 Stephan Schuberth
h3. Check installation
47 1 Stephan Schuberth
48 1 Stephan Schuberth
If this does not work, it is probably because there is no ruby at /usr/bin to be found. 
49 1 Stephan Schuberth
<pre>ruby -v</pre>
50 22 Stephan Schuberth
If it works, skip directly to "RubyGems 1.4.2".
51 22 Stephan Schuberth
52 1 Stephan Schuberth
53 6 Stephan Schuberth
h3. Fix dependencies
54 1 Stephan Schuberth
55 1 Stephan Schuberth
(Only in case _ruby -v_ is *NOT* working)
56 1 Stephan Schuberth
<pre>which ruby  # TO CHECK WHERE IT SHOULD BE
57 1 Stephan Schuberth
whereis ruby  # TO CHECK WHERE IT IS INSTALLED</pre>
58 1 Stephan Schuberth
_which_ returns like /usr/bin/ along with other directories (where ruby is expected to be), and _whereis_ returns like /usr/local/bin/ruby (thats where ruby actually lies).
59 1 Stephan Schuberth
60 6 Stephan Schuberth
h4. Fix via adding /usr/local/bin to $PATH
61 6 Stephan Schuberth
62 9 Stephan Schuberth
(Do this with your editor of choice, if you do not like nano.)
63 6 Stephan Schuberth
<pre>nano /etc/profile</pre>
64 6 Stephan Schuberth
65 6 Stephan Schuberth
Make the section with _pathmunge_ look alike like this:
66 6 Stephan Schuberth
<pre>#Path manupulation
67 6 Stephan Schuberth
if [ "$EUID" = "0" ]; then
68 6 Stephan Schuberth
    pathmunge /sbin
69 6 Stephan Schuberth
    pathmunge /usr/sbin
70 6 Stephan Schuberth
    pathmunge /usr/local/sbin
71 6 Stephan Schuberth
    pathmunge /usr/local/bin  # ADDED THIS
72 6 Stephan Schuberth
else
73 6 Stephan Schuberth
    pathmunge /usr/local/bin after  # ADDED THIS
74 6 Stephan Schuberth
    pathmunge /usr/local/sbin after
75 6 Stephan Schuberth
    pathmunge /usr/sbin after
76 6 Stephan Schuberth
    pathmunge /sbin
77 6 Stephan Schuberth
fi</pre>
78 6 Stephan Schuberth
79 6 Stephan Schuberth
OR ADD THIS AT THE END OF THE FILE:
80 6 Stephan Schuberth
81 6 Stephan Schuberth
<pre>nano /etc/profile
82 6 Stephan Schuberth
export PATH="$PATH:/usr/local/bin"</pre>
83 6 Stephan Schuberth
84 15 Stephan Schuberth
This sets the PATH for all Users beside root. For this setup you want to change the PATH for root, too:
85 6 Stephan Schuberth
86 6 Stephan Schuberth
<pre>nano ~/.bashrc
87 1 Stephan Schuberth
export PATH="$PATH:/usr/local/bin"</pre>
88 15 Stephan Schuberth
89 15 Stephan Schuberth
Logout your user and login again, to make the changes work.
90 6 Stephan Schuberth
91 6 Stephan Schuberth
h4. Fix via Symlink Creation 
92 6 Stephan Schuberth
93 7 Stephan Schuberth
This is not recommended, since if the ruby dependency is broken, others will likely be later on, too. Repair this by adding the folder to the $PATH variable like described before, else _gem_, _rake_, _bundle_, _passenger-install-apache2-module_ will not work either... you would have to creat symlinks for them, too.
94 6 Stephan Schuberth
Symlinks are created like this
95 6 Stephan Schuberth
96 1 Stephan Schuberth
<pre>ln -s /usr/local/bin/ruby /usr/bin/ruby</pre>
97 6 Stephan Schuberth
98 8 Stephan Schuberth
h4. Verify ruby to be working
99 6 Stephan Schuberth
100 16 Stephan Schuberth
<pre>which ruby  # MUST RETURN PATH TO RUBY
101 16 Stephan Schuberth
ruby -v  # MUST RETURN RUBY VERSION
102 1 Stephan Schuberth
cd ..</pre>
103 16 Stephan Schuberth
104 19 Stephan Schuberth
Now it has to work. When changing $PATH variable, did you log out and log on again with your current user?
105 18 Stephan Schuberth
If this does not function properly, other things later on will also not work.
106 1 Stephan Schuberth
107 1 Stephan Schuberth
h2. RubyGems 1.4.2 
108 1 Stephan Schuberth
109 1 Stephan Schuberth
*Does not work with Gems 1.5!*
110 1 Stephan Schuberth
111 1 Stephan Schuberth
h3. Download
112 1 Stephan Schuberth
113 1 Stephan Schuberth
<pre>wget http://production.cf.rubygems.org/rubygems/rubygems-1.4.2.tgz</pre>
114 1 Stephan Schuberth
115 1 Stephan Schuberth
h3. Untar
116 1 Stephan Schuberth
117 1 Stephan Schuberth
<pre>tar zxvf rubygems-1.4.2.tgz</pre>
118 1 Stephan Schuberth
119 1 Stephan Schuberth
h3. Setup
120 1 Stephan Schuberth
121 1 Stephan Schuberth
<pre>cd rubygems-1.4.2
122 1 Stephan Schuberth
ruby setup.rb</pre>
123 1 Stephan Schuberth
124 1 Stephan Schuberth
h3. Check installation
125 1 Stephan Schuberth
126 1 Stephan Schuberth
<pre>gem -v</pre>
127 1 Stephan Schuberth
128 21 Stephan Schuberth
h3. Do things work?
129 1 Stephan Schuberth
130 21 Stephan Schuberth
... else the cause is the same as with the ruby problem before...
131 1 Stephan Schuberth
132 1 Stephan Schuberth
h2. Passenger
133 1 Stephan Schuberth
134 1 Stephan Schuberth
h3. Regular install method
135 1 Stephan Schuberth
136 1 Stephan Schuberth
Requires gcc.
137 1 Stephan Schuberth
138 1 Stephan Schuberth
<pre>gem install passenger
139 1 Stephan Schuberth
passenger-install-apache2-module</pre>
140 1 Stephan Schuberth
141 14 Stephan Schuberth
The install process is interactive and you wil be told what to do. How to install missing dependencies is described exactly. JUST READ!
142 1 Stephan Schuberth
143 1 Stephan Schuberth
h3. Alternative install method 
144 1 Stephan Schuberth
145 1 Stephan Schuberth
Install mod_passenger RPM for Apache from the following location:
146 1 Stephan Schuberth
147 1 Stephan Schuberth
> http://passenger.stealthymonkeys.com/
148 1 Stephan Schuberth
149 1 Stephan Schuberth
_RHEL/CentOS 5_
150 1 Stephan Schuberth
<pre>rpm -Uvh http://passenger.stealthymonkeys.com/rhel/5/passenger-release.noarch.rpm
151 1 Stephan Schuberth
yum install mod_passenger</pre>
152 1 Stephan Schuberth
153 1 Stephan Schuberth
_RHEL/CentOS 6_
154 1 Stephan Schuberth
<pre>rpm --import http://passenger.stealthymonkeys.com/RPM-GPG-KEY-stealthymonkeys.asc
155 1 Stephan Schuberth
yum install http://passenger.stealthymonkeys.com/rhel/6/passenger-release.noarch.rpm
156 1 Stephan Schuberth
yum install mod_passenger</pre>
157 1 Stephan Schuberth
158 1 Stephan Schuberth
h2. Restart Apache
159 1 Stephan Schuberth
160 1 Stephan Schuberth
<pre>service httpd restart</pre>
161 1 Stephan Schuberth
162 1 Stephan Schuberth
h1. Install Redmine
163 1 Stephan Schuberth
164 1 Stephan Schuberth
h3. Download
165 1 Stephan Schuberth
166 1 Stephan Schuberth
Download page: 
167 1 Stephan Schuberth
> http://rubyforge.org/frs/?group_id=1850
168 1 Stephan Schuberth
169 1 Stephan Schuberth
<pre>wget http://rubyforge.org/frs/download.php/75910/redmine-1.3.2.tar.gz # GET LATEST VERSION ON RUBYFORGE</pre>
170 1 Stephan Schuberth
171 1 Stephan Schuberth
h3. Untar
172 1 Stephan Schuberth
173 1 Stephan Schuberth
<pre>tar zxvf redmine-1.3.2.tar.gz</pre>
174 1 Stephan Schuberth
175 1 Stephan Schuberth
h3. Copy the folder to its HTTP document root folder
176 1 Stephan Schuberth
177 1 Stephan Schuberth
<pre>mkdir /var/www/redmine
178 1 Stephan Schuberth
cp -av redmine-1.3.2/* /var/www/redmine</pre>
179 1 Stephan Schuberth
180 13 Stephan Schuberth
h1. Link Redmine to the Database
181 13 Stephan Schuberth
182 13 Stephan Schuberth
h2. Install MySQL DB Server
183 13 Stephan Schuberth
184 13 Stephan Schuberth
<pre>yum install mysql-server
185 13 Stephan Schuberth
chkconfig mysqld on
186 13 Stephan Schuberth
service mysqld start
187 13 Stephan Schuberth
/usr/bin/mysql_secure_installation</pre>
188 13 Stephan Schuberth
189 13 Stephan Schuberth
h2. Create a MySQL database to use with Redmine
190 13 Stephan Schuberth
191 13 Stephan Schuberth
h3. Latest MySQL Version
192 13 Stephan Schuberth
193 13 Stephan Schuberth
> start the mysql client (@mysql -u root -p@) and enter the following commands:
194 13 Stephan Schuberth
> > <pre>create database redmine character set utf8;
195 13 Stephan Schuberth
create user 'redmine'@'localhost' identified by 'my_password';
196 13 Stephan Schuberth
grant all privileges on redmine.* to 'redmine'@'localhost'; </pre>
197 13 Stephan Schuberth
198 13 Stephan Schuberth
h3. For versions of MySQL prior to 5.0.2
199 13 Stephan Schuberth
200 13 Stephan Schuberth
> Skip the 'create user' step and do instead:
201 13 Stephan Schuberth
> >  <pre> grant all privileges on redmine.* to 'redmine'@'localhost' identified by 'my_password';</pre>
202 13 Stephan Schuberth
203 13 Stephan Schuberth
Now the database is created and a user to be used with it. Also the user has the rights to work on the database that was created.
204 13 Stephan Schuberth
205 13 Stephan Schuberth
h2. Configure /var/www/redmine/config/database.yml 
206 13 Stephan Schuberth
207 13 Stephan Schuberth
<pre>cp database.yml.example database.yml</pre>
208 13 Stephan Schuberth
209 13 Stephan Schuberth
TODO: describe what to change there...
210 13 Stephan Schuberth
211 1 Stephan Schuberth
h1. Rails Settings
212 1 Stephan Schuberth
213 1 Stephan Schuberth
h2. Dependency management with bundler
214 1 Stephan Schuberth
215 1 Stephan Schuberth
For more info go to the "bundler site":http://gembundler.com/.
216 1 Stephan Schuberth
217 1 Stephan Schuberth
h3. Install
218 1 Stephan Schuberth
219 1 Stephan Schuberth
<pre>gem install bundler</pre>
220 1 Stephan Schuberth
221 1 Stephan Schuberth
h3. Create Gemfile
222 1 Stephan Schuberth
223 1 Stephan Schuberth
You can of course use vi/vim as your editor of choice, if you know what you are doing. ;) 
224 1 Stephan Schuberth
<pre>nano /var/www/redmine/Gemfile</pre>
225 1 Stephan Schuberth
226 1 Stephan Schuberth
h3. Register gems
227 1 Stephan Schuberth
228 1 Stephan Schuberth
Put the following into the file you just opened:
229 1 Stephan Schuberth
<pre># file: /var/www/redmine/Gemfile
230 1 Stephan Schuberth
source "http://rubygems.org"
231 1 Stephan Schuberth
gem "rake", "0.8.3"
232 1 Stephan Schuberth
gem "rack", "1.1.0"
233 1 Stephan Schuberth
gem "i18n", "0.4.2"
234 1 Stephan Schuberth
gem "rubytree", "0.5.2", :require => "tree"
235 1 Stephan Schuberth
gem "RedCloth", "~>4.2.3", :require => "redcloth" # for CodeRay
236 1 Stephan Schuberth
gem "mysql"
237 1 Stephan Schuberth
gem "coderay", "~>0.9.7"</pre>
238 1 Stephan Schuberth
Save and exit the editor.
239 1 Stephan Schuberth
240 20 Stephan Schuberth
h3. Install the provided dependencies
241 1 Stephan Schuberth
242 10 Stephan Schuberth
<pre>cd /var/www/redmine
243 10 Stephan Schuberth
bundle install</pre>
244 1 Stephan Schuberth
245 12 Stephan Schuberth
h2. Set environment to "production" 
246 12 Stephan Schuberth
247 12 Stephan Schuberth
Rails has the concept of environments to represent the stages of an application’s lifecycle: test, development, and production by default. 
248 12 Stephan Schuberth
Specify your choice with the RAILS_ENV environment variable. 
249 12 Stephan Schuberth
Production has less verbose logging and is a bit faster, testing and development environment are not needed anyway for your Redmine.
250 12 Stephan Schuberth
251 12 Stephan Schuberth
Uncomment the following line in file redmine/config/environment.rb:
252 12 Stephan Schuberth
253 12 Stephan Schuberth
<pre>ENV['RAILS_ENV'] ||= 'production'</pre>
254 12 Stephan Schuberth
255 12 Stephan Schuberth
h2. Generate the session store
256 12 Stephan Schuberth
257 12 Stephan Schuberth
<pre>RAILS_ENV=production bundle exec rake generate_session_store</pre>
258 12 Stephan Schuberth
259 12 Stephan Schuberth
h2. Migrate the database models
260 12 Stephan Schuberth
261 12 Stephan Schuberth
<pre>RAILS_ENV=production bundle exec rake db:migrate</pre>
262 12 Stephan Schuberth
263 12 Stephan Schuberth
h2. Load default data (optional)
264 12 Stephan Schuberth
265 12 Stephan Schuberth
<pre>RAILS_ENV=production bundle exec rake redmine:load_default_data</pre>
266 12 Stephan Schuberth
267 12 Stephan Schuberth
Follow instructions.
268 12 Stephan Schuberth
269 12 Stephan Schuberth
h2. Rename dispatch CGI files in /var/www/redmine/public/
270 12 Stephan Schuberth
271 12 Stephan Schuberth
<pre>
272 12 Stephan Schuberth
mv dispatch.cgi.example dispatch.cgi
273 12 Stephan Schuberth
mv dispatch.fcgi.example dispatch.fcgi
274 12 Stephan Schuberth
mv dispatch.rb.example dispatch.rb
275 12 Stephan Schuberth
</pre>
276 1 Stephan Schuberth
277 1 Stephan Schuberth
h1. Apache Settings
278 11 Stephan Schuberth
279 11 Stephan Schuberth
h2. Configure Apache to host the documents
280 11 Stephan Schuberth
281 11 Stephan Schuberth
more information can be found here: [[HowTo configure Apache to run Redmine]]
282 1 Stephan Schuberth
283 1 Stephan Schuberth
h2. Edit .htaccess file for CGI dispatch configuration
284 1 Stephan Schuberth
285 1 Stephan Schuberth
<pre>
286 1 Stephan Schuberth
mv htaccess.fcgi.example .htaccess
287 1 Stephan Schuberth
</pre>
288 1 Stephan Schuberth
289 1 Stephan Schuberth
h2. Fix rights for the apache user
290 1 Stephan Schuberth
291 1 Stephan Schuberth
<pre>
292 1 Stephan Schuberth
cd ..
293 1 Stephan Schuberth
chown -R apache:apache redmine-1.x
294 1 Stephan Schuberth
chmod -R 755 redmine-1.x
295 1 Stephan Schuberth
</pre>
296 1 Stephan Schuberth
297 1 Stephan Schuberth
298 1 Stephan Schuberth
299 1 Stephan Schuberth
300 1 Stephan Schuberth
301 1 Stephan Schuberth
302 1 Stephan Schuberth
This should be everything.
303 1 Stephan Schuberth
304 5 Stephan Schuberth
305 5 Stephan Schuberth
*Redmine is now installed and usable.*
306 1 Stephan Schuberth
307 1 Stephan Schuberth
*Enjoy!*