Project

General

Profile

HowTo Install Redmine in a sub-URI on Windows with Apache » History » Version 12

Etienne Massip, 2011-04-15 09:59
Removed RubyGem system update as current Redmine stable does not support RubyGems >= 1.5.0

1 1 Jack Kurzecki
h1. HowTo Install Redmine in a sub-URI on Windows with Apache
2
3
{{>toc}}
4
5 9 Jack Kurzecki
bq. Following the steps below exactly as listed will produce a working *Redmine* installation hosted under *http://localhost/redmine* sub-URI on Windows XP/2003/2008 x86/x64 with Apache HTTP Server 2.2.x, MySQL 5.1.x, PHP 5.3.x and Ruby 1.8.7.
6 11 Jack Kurzecki
This walk-through was tested with *Redmine 1.0.4.devel.4543* but should work with any version >= 0.8 .
7 2 Jack Kurzecki
The intended audience for this walk-through are Windows users.
8 1 Jack Kurzecki
9 4 Jack Kurzecki
+In case you encounter problems, please look at "*this forum thread*":http://www.redmine.org/boards/1/topics/10162 for information about some known issues and their workarounds+
10
11 1 Jack Kurzecki
h2. Install Apache HTTP server 2.2.x
12
13 3 Jack Kurzecki
# Download *"Win32 Binary without crypto (no mod_ssl) (MSI Installer)"* or *"Win32 Binary including OpenSSL (MSI Installer)"*, depending if you intend to use SSL on your webserver, from "here":http://httpd.apache.org/download.cgi
14 9 Jack Kurzecki
# Install to *C:\webserver\Apache\*
15 1 Jack Kurzecki
16
h2. Install MySQL 5.1.x
17
18 9 Jack Kurzecki
# Download *"Windows (x86, 32-bit), MSI Installer - Essentials - Recommended"* from "here":http://dev.mysql.com/downloads/mysql/5.1.html#win32
19 1 Jack Kurzecki
#* _(the *64-bit* version could be installed on x64 Windows platforms, but the *32-bit* version is +recommended+ and it works well on both x86 and x64 versions of Windows.)_
20 9 Jack Kurzecki
# Install to *C:\webserver\MySQL\*
21
#* During initial setup:
22
#*# (_optional:_) set data files installation directory to *C:\webserver\MySQL_Data\*
23
#* During Server Instance Configuration Wizard:
24
#*# (_optional:_) Add firewall exception for the port used
25
#*# set +default character set+ to "Best Support for Multilingualism" *UTF8*
26 1 Jack Kurzecki
#*# select "Include Bin Directory in Windows PATH"
27
28 9 Jack Kurzecki
h2. Install MySQL Workbench 5.2.x
29 1 Jack Kurzecki
30 9 Jack Kurzecki
# Download *"Windows (x86, 32-bit), MSI Installer"* from "here":http://dev.mysql.com/downloads/workbench/
31
# Install to *C:\webserver\MySQL_Workbench\*
32 4 Jack Kurzecki
33 3 Jack Kurzecki
h2. Install PHP 5.3.x
34 1 Jack Kurzecki
35 9 Jack Kurzecki
# Download *"VC6 x86 Thread Safe - Installer"* from "here":http://windows.php.net/download/
36
# Install to *C:\webserver\PHP\*
37 1 Jack Kurzecki
#* During setup:
38 9 Jack Kurzecki
#*# for webserver, choose "Apache 2.2.x Module"
39
#*# configuration directory is "C:\webserver\Apache\conf\"
40
#*# you can leave all default Extensions as they are, optionally adding "Internationalization" and "Multi-Byte String"
41 1 Jack Kurzecki
42 9 Jack Kurzecki
h2. Install Ruby 1.8.7 with RubyGems
43 1 Jack Kurzecki
44 11 Jack Kurzecki
* _At the time of writing this document the latest version of Ruby was 1.9.2, however for best compatibility use +Ruby version 1.8.7+._
45 1 Jack Kurzecki
46 11 Jack Kurzecki
# Download *"rubyinstaller-1.8.7-p302.exe"* from "here":http://rubyforge.org/frs/?group_id=167
47 9 Jack Kurzecki
# Install to *C:\webserver\Ruby\*
48 1 Jack Kurzecki
# During setup, select *"Add Ruby executables to your PATH"*
49 3 Jack Kurzecki
# Verify Ruby version
50 9 Jack Kurzecki
#* Open command window, execute: <pre>
51 2 Jack Kurzecki
ruby -v
52 1 Jack Kurzecki
</pre>
53 9 Jack Kurzecki
#** expected output:<pre>
54 11 Jack Kurzecki
ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
55 7 Jérôme Souquières
</pre>
56 9 Jack Kurzecki
# Verify RubyGems version
57
#* in command window, execute: <pre>
58
gem -v
59 3 Jack Kurzecki
</pre>
60 9 Jack Kurzecki
#** expected output:<pre>
61
1.3.7
62 3 Jack Kurzecki
</pre>
63 12 Etienne Massip
##* _At the time of writing this document the latest version of RubyGems was 1.3.7. *Versions >= 1.5.0 won't work with Redmine 1.1.x*._
64 1 Jack Kurzecki
65 9 Jack Kurzecki
* _If you get errors about missing "SSLEAY32.dll", install PHP as shown above and this dll will become available_
66
67 1 Jack Kurzecki
h2. Additional gems
68
69
* _mongrel-service and win32-service gems have to be downloaded manually. Download locations are added to sections below._
70
71
h3. Install Rake
72
73 3 Jack Kurzecki
* _At the time of writing this document the latest version of Rake was 0.8.7. Newer versions should work too._
74 2 Jack Kurzecki
75
# Install Rake gem
76 9 Jack Kurzecki
#* in command window, execute: <pre>
77 1 Jack Kurzecki
gem install rake</pre>
78 9 Jack Kurzecki
#** expected output:<pre>
79 1 Jack Kurzecki
Successfully installed rake-0.8.7
80
</pre>
81
82
h3. Install Rails
83
84 11 Jack Kurzecki
* _At the time of writing this document, the latest version of Rails is 3.0.3, but *Redmine 1.0.4* installation requires *Rails 2.3.5*._
85 1 Jack Kurzecki
86
# Install Rails gems
87 9 Jack Kurzecki
#* in command window, execute: <pre>
88 1 Jack Kurzecki
gem install rails -v=2.3.5
89 2 Jack Kurzecki
</pre>
90 9 Jack Kurzecki
#** expected output:<pre>
91 1 Jack Kurzecki
Successfully installed activesupport-2.3.5
92
Successfully installed activerecord-2.3.5
93 9 Jack Kurzecki
Successfully installed rack-1.0.1
94 1 Jack Kurzecki
Successfully installed actionpack-2.3.5
95
Successfully installed actionmailer-2.3.5
96
Successfully installed activeresource-2.3.5
97
Successfully installed rails-2.3.5
98
7 gems installed
99
</pre>
100
101 11 Jack Kurzecki
102
h3. Install i18n
103
104
* _At the time of writing this document, the latest version of i18n is 0.5, but *Redmine 1.0.4* installation requires *i18n 0.4.2*._
105
106
# Install i18n gem
107
#* in command window, execute: <pre>
108
gem install -v=0.4.2 i18n
109
</pre>
110
#** expected output:<pre>
111
Successfully installed i18n-0.4.2
112
1 gem installed
113
</pre>
114
115 1 Jack Kurzecki
h3. Install Mongrel
116
117
* _At the time of writing this document the latest version of Mongrel was 1.1.5. Newer versions should work too._
118
* "_Project page_":http://rubyforge.org/projects/mongrel/
119 3 Jack Kurzecki
120 1 Jack Kurzecki
# Install Mongrel gems
121 9 Jack Kurzecki
#* in command window, execute: <pre>
122 1 Jack Kurzecki
gem install mongrel
123
</pre>
124 9 Jack Kurzecki
#** expected output:<pre>
125 1 Jack Kurzecki
Successfully installed gem_plugin-0.2.3
126
Successfully installed cgi_multipart_eof_fix-2.5.0
127 9 Jack Kurzecki
Successfully installed mongrel-1.1.5-x86-mingw32
128
3 gems installed
129 1 Jack Kurzecki
</pre>
130
131
h3. Install mysql gem
132
133
* _At the time of writing this document the latest version of mysql gem was 2.8.1. Newer versions should work too._
134
* It drastically improves page generation speed.
135
136 3 Jack Kurzecki
# Install mysql gem
137 9 Jack Kurzecki
#* in command window, execute: <pre>
138 1 Jack Kurzecki
gem install mysql
139
</pre>
140 9 Jack Kurzecki
#** expected output:<pre>
141
Successfully installed mysql-2.8.1-x86-mingw32
142
1 gem installed
143
Installing ri documentation for mysql-2.8.1-x86-mingw32...
144
No definition for (...)
145 1 Jack Kurzecki
</pre>
146 9 Jack Kurzecki
#** _The gem was made for MySQL 5.0 so there are some additional features in 5.1 which will not be defined, so you will see a number of lines about missing definitions, but it does not cause any problems_
147 1 Jack Kurzecki
148
h3. Install mongrel-service + win32-service gems
149
150
* _At the time of writing this document the latest version of win32-service was 0.7 which does *NOT* work with Ruby 1.8.7_
151
* *Use only win32-service version 0.5.2 for Redmine deployment.*
152
153 9 Jack Kurzecki
# Download *"mongrel_service-0.3.4-i386-mswin32.gem"* from "here":http://rubyforge.org/frs/?group_id=1306
154
# Move *mongrel_service-0.3.4-i386-mswin32.gem* to *C:\webserver\*
155 1 Jack Kurzecki
# Download *"win32-service-0.5.2-mswin32.gem"* from "here":http://files.ruby.inoack.com/win32utils/
156 9 Jack Kurzecki
#* _This file is also attached at the bottom of this wiki page_
157
# Move *win32-service-0.5.2-mswin32.gem* to *C:\webserver\*
158 3 Jack Kurzecki
# Install the gem
159 1 Jack Kurzecki
#* in command window, execute: <pre>
160 9 Jack Kurzecki
cd C:\webserver\
161
gem install mongrel_service
162
</pre>
163
#** expected output:<pre>
164 1 Jack Kurzecki
Successfully installed win32-service-0.5.2-x86-mswin32
165 9 Jack Kurzecki
Successfully installed mongrel_service-0.3.4-x86-mswin32
166 1 Jack Kurzecki
2 gems installed
167
</pre>
168
# Delete the two .gem files from C:\webserver\
169
170 3 Jack Kurzecki
h2. Install Redmine
171 9 Jack Kurzecki
172 11 Jack Kurzecki
* _Procedure below assumes we will be installing Redmine 1.0.4, but it also works with any revisions >= r3235_
173 9 Jack Kurzecki
174 11 Jack Kurzecki
# Download *"redmine-1.0.4.zip"* from "here":http://rubyforge.org/frs/?group_id=1850
175
# Extract the contents of the +redmine-1.0.4+ directory in the archive to *C:\webserver\Redmine*
176 9 Jack Kurzecki
# Log into MySQL as *root* using "MySQL Workbench". You can also use command prompt or another tool, such as "MySQL GUI Tools" or "phpMyAdmin".
177
## "Open connection to Start Querying"
178 1 Jack Kurzecki
## In SQL Query window enter the following script: <pre>
179
create database redmine character set utf8;
180
create user 'redmineUser'@'localhost' identified by 'myPassword';
181
grant all privileges on redmine.* to 'redmineUser'@'localhost';
182 9 Jack Kurzecki
</pre>
183
## "Execute SQL Script in Connected Server"
184
##* _You should of course change *redmineUser* and *myPassword* to something different._
185
# Copy *C:\webserver\Redmine\config\database.yml.example* to *C:\webserver\Redmine\config\database.yml*
186 3 Jack Kurzecki
# Edit *C:\webserver\Redmine\config\database.yml* file to configure your database settings for "production" environment. It should look like this:<pre>
187
production:
188
  adapter: mysql
189 9 Jack Kurzecki
  database: redmine
190 1 Jack Kurzecki
  host: localhost
191 9 Jack Kurzecki
  username: redmineUser
192
  password: myPassword
193
  encoding: utf8
194
</pre>
195
## Set username and password to the values entered in the SQL script above.
196
## Save and close the file.
197
# Create (or update) Redmine database tables
198
#* in command window, execute: <pre>
199
cd C:\webserver\Redmine
200
set RAILS_ENV=production
201 1 Jack Kurzecki
rake generate_session_store
202
rake db:migrate
203 9 Jack Kurzecki
</pre>
204
#** _If you encounter this error: *Mysql::Error: query: not connected: CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB*_ :
205
#**# download *libmySQL.dll* from "here":http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/
206
#**# move this .dll file to *C:\webserver\Ruby\bin\*
207
#**# in command window, again execute: <pre>
208
rake db:migrate
209
</pre>
210
# If this is a fresh install, you can pre-populate the tables with default data
211
#* in command window, execute: <pre>
212 1 Jack Kurzecki
rake redmine:load_default_data
213
</pre>
214 9 Jack Kurzecki
# _Assuming that we will be hosting Redmine under http://localhost/redmine_
215
#* Edit *C:\webserver\Redmine\config\environment.rb* file to configure Redmine to work as a sub-URI (Apache configuration is also required and is listed later on in this document).
216 1 Jack Kurzecki
#* add the following line at the bottom of the file:<pre>
217
Redmine::Utils::relative_url_root = "/redmine" 
218
</pre>
219
#* save and close the file.
220 9 Jack Kurzecki
#* _This is a preferred way of setting up the application prefix. *Mongrel_rails service "--prefix" directive does +NOT+ work with Rails 2.3.x*_
221 11 Jack Kurzecki
#** Optionally, you can add a following initializer, but *_ONLY IF_* you want to use "--prefix" in "Mongrel_rails service" command +instead+ of changing "environment.rb":
222
#*** Create a file config/initializers/patch_for_mongrel.rb  [name of file can be anything]:
223 1 Jack Kurzecki
<pre>
224 3 Jack Kurzecki
# Fix for mongrel which still doesn't know about Rails 2.2's changes, 
225 8 Tiemo Vorschuetz
# We provide a backwards compatible wrapper around the new
226
# ActionController::base.relative_url_root,
227
# so it can still be called off of the actually non-existing
228
# AbstractRequest class.
229
230
module ActionController
231
  class AbstractRequest < ActionController::Request
232
    def self.relative_url_root=(path)
233
      ActionController::Base.relative_url_root=(path)
234
    end
235
    def self.relative_url_root
236
      ActionController::Base.relative_url_root
237
    end
238
  end
239
end
240
#
241
# Thanks to http://www.ruby-forum.com/topic/190287
242
</pre>
243
244
h2. Setup windows services
245
246
* Memory usage is greatly affected by the number of mongrels running. Keep that in mind when deciding on how many processes you want to run. For example, memory usage on Windows Server 2003 x64 SP2:
247 1 Jack Kurzecki
** Apache = 5MB + 20MB + 40MB = 65MB
248
** MySQL = 35MB
249 3 Jack Kurzecki
** Mongrel cluster = number-of-mongrel_rails-services x (3MB + 90MB) = 279MB (@3 processes)
250
251
# Create windows services
252 9 Jack Kurzecki
## in command window, execute: <pre>
253
mongrel_rails service::install -N mongrel_redmine_3001 -D "Mongrel serving Redmine on 3001" -p 3001 -e production -c C:\webserver\Redmine
254
mongrel_rails service::install -N mongrel_redmine_3002 -D "Mongrel serving Redmine on 3002" -p 3002 -e production -c C:\webserver\Redmine
255 1 Jack Kurzecki
mongrel_rails service::install -N mongrel_redmine_3003 -D "Mongrel serving Redmine on 3003" -p 3003 -e production -c C:\webserver\Redmine
256
</pre>
257
# Start windows services, which in turn will start mongrel servers
258
## in command window, execute: <pre>
259
net start mongrel_redmine_3001
260
net start mongrel_redmine_3002
261
net start mongrel_redmine_3003
262 2 Jack Kurzecki
</pre>
263
# Go to the Windows Services list and set all "Mongrel serving Redmine on 300#" services to start automatically
264 1 Jack Kurzecki
## in command window, execute: <pre>
265
services.msc /s
266 2 Jack Kurzecki
</pre>
267 1 Jack Kurzecki
## find each one of "Mongrel serving Redmine on 300#" services
268
## right click, select *Properties*
269
## set *Startup type* to *"Automatic"*
270 10 Jozef Izso
## press OK and repeat for the remaining Mongrel services.
271
#* _Alternatively you can execute this command on elevated command prompt for each mongrel service installed:_ <pre>
272
sc config mongrel_redmine_3001 start= auto
273 3 Jack Kurzecki
</pre>
274
275
h2. Configure Apache 2.2.x as proxy to Mongrel cluster
276
277 1 Jack Kurzecki
* _Procedure below assumes we will be hosting Redmine under http://localhost/redmine and must match the *relative_url_root* set above_
278 9 Jack Kurzecki
279 1 Jack Kurzecki
# Open *C:\webserver\Apache\conf\httpd.conf*
280 3 Jack Kurzecki
# At the bottom of this file add the following line: <pre>
281 1 Jack Kurzecki
Include conf/httpd-proxy-mongrel.conf
282 9 Jack Kurzecki
</pre>
283 1 Jack Kurzecki
# Create a file *C:\webserver\Apache\conf\httpd-proxy-mongrel.conf*
284 9 Jack Kurzecki
# Enter the following: <pre>
285
<IfModule !mod_proxy.c>
286
	LoadModule proxy_module modules/mod_proxy.so
287
</IfModule>
288
<IfModule !mod_proxy_http.c>
289
	LoadModule proxy_http_module modules/mod_proxy_http.so
290
</IfModule>
291
<IfModule !mod_proxy_balancer.c>
292
	LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
293 1 Jack Kurzecki
</IfModule>
294
295
ProxyPass /redmine balancer://redmine_cluster
296
ProxyPassReverse /redmine balancer://redmine_cluster
297
298 9 Jack Kurzecki
<Proxy balancer://redmine_cluster>
299
    BalancerMember http://127.0.0.1:3001
300
    BalancerMember http://127.0.0.1:3002
301 1 Jack Kurzecki
    BalancerMember http://127.0.0.1:3003
302 3 Jack Kurzecki
</Proxy>
303
</pre>
304
# Restart the Apache service.
305 9 Jack Kurzecki
#* in command window, execute: <pre>
306
C:\webserver\Apache\bin\httpd.exe -w -n "Apache2.2" -k stop
307 1 Jack Kurzecki
C:\webserver\Apache\bin\httpd.exe -w -n "Apache2.2" -k start
308
</pre>
309
310 2 Jack Kurzecki
311
312 9 Jack Kurzecki
*+DONE!+*
313 2 Jack Kurzecki
Your local installation of Redmine is now accessible at http://localhost/redmine
314 9 Jack Kurzecki
315 3 Jack Kurzecki
316 9 Jack Kurzecki
h2. Additional components
317 1 Jack Kurzecki
318
h3. Install RMagic
319 9 Jack Kurzecki
320
# Download *"RMagick-2.12.0-ImageMagick-6.5.6-8-Q8.zip"* or a later version from "here":http://rubyforge.org/frs/?group_id=12
321
# Extract *"rmagick-2.12.0-x86-mswin32.gem"* to *C:\webserver\*
322
# Install *"ImageMagick-6.5.6-8-Q8-windows-dll.exe"* to *C:\webserver\ImageMagick*
323
# Install the RMagic gem
324
#* in command window, execute: <pre>
325
cd C:\webserver
326 1 Jack Kurzecki
gem install rmagick --local
327 9 Jack Kurzecki
</pre>
328
#** expected output:<pre>
329
Successfully installed rmagick-2.12.0-x86-mswin32
330 1 Jack Kurzecki
1 gem installed
331 9 Jack Kurzecki
</pre>
332
# Delete the .gem file from C:\webserver\
333 1 Jack Kurzecki
# Reboot your server. (I was unsuccessful trying to get it to work without rebooting)
334 9 Jack Kurzecki
335
336
h3. Add redmine_attach_screenshot plugin
337
338 11 Jack Kurzecki
# download source from "here":https://github.com/blondak/redmine_attach_screenshot
339 9 Jack Kurzecki
# Extract the archive to *C:\webserver\Redmine\vendor\plugins\redmine_attach_screenshot*
340
# Restart the Mongrel cluster
341
#* in command window, execute: <pre>
342
net stop mongrel_redmine_3001
343
net stop mongrel_redmine_3002
344
net stop mongrel_redmine_3003
345
net start mongrel_redmine_3001
346
net start mongrel_redmine_3002
347
net start mongrel_redmine_3003
348
</pre>
349
350
351
352 1 Jack Kurzecki
+In case you encounter problems, please look at "*this forum thread*":http://www.redmine.org/boards/1/topics/10162 for information about some known issues and their workarounds+