Project

General

Profile

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

Jack Kurzecki, 2010-12-19 10:55
updated for Redmine 1.0.4

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 9 Jack Kurzecki
##* _At the time of writing this document the latest version of RubyGems was 1.3.7. Newer versions should work too._
64
# Check for RubyGems update
65
#* in command window, execute: <pre>
66 1 Jack Kurzecki
gem update --system
67
</pre>
68 9 Jack Kurzecki
#** expected output:<pre>
69
Updating RubyGems
70
Nothing to update
71
</pre>
72 1 Jack Kurzecki
73 9 Jack Kurzecki
* _If you get errors about missing "SSLEAY32.dll", install PHP as shown above and this dll will become available_
74
75 1 Jack Kurzecki
h2. Additional gems
76
77
* _mongrel-service and win32-service gems have to be downloaded manually. Download locations are added to sections below._
78
79
h3. Install Rake
80
81 3 Jack Kurzecki
* _At the time of writing this document the latest version of Rake was 0.8.7. Newer versions should work too._
82 2 Jack Kurzecki
83
# Install Rake gem
84 9 Jack Kurzecki
#* in command window, execute: <pre>
85 1 Jack Kurzecki
gem install rake</pre>
86 9 Jack Kurzecki
#** expected output:<pre>
87 1 Jack Kurzecki
Successfully installed rake-0.8.7
88
</pre>
89
90
h3. Install Rails
91
92 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*._
93 1 Jack Kurzecki
94
# Install Rails gems
95 9 Jack Kurzecki
#* in command window, execute: <pre>
96 1 Jack Kurzecki
gem install rails -v=2.3.5
97 2 Jack Kurzecki
</pre>
98 9 Jack Kurzecki
#** expected output:<pre>
99 1 Jack Kurzecki
Successfully installed activesupport-2.3.5
100
Successfully installed activerecord-2.3.5
101 9 Jack Kurzecki
Successfully installed rack-1.0.1
102 1 Jack Kurzecki
Successfully installed actionpack-2.3.5
103
Successfully installed actionmailer-2.3.5
104
Successfully installed activeresource-2.3.5
105
Successfully installed rails-2.3.5
106
7 gems installed
107
</pre>
108
109 11 Jack Kurzecki
110
h3. Install i18n
111
112
* _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*._
113
114
# Install i18n gem
115
#* in command window, execute: <pre>
116
gem install -v=0.4.2 i18n
117
</pre>
118
#** expected output:<pre>
119
Successfully installed i18n-0.4.2
120
1 gem installed
121
</pre>
122
123 1 Jack Kurzecki
h3. Install Mongrel
124
125
* _At the time of writing this document the latest version of Mongrel was 1.1.5. Newer versions should work too._
126
* "_Project page_":http://rubyforge.org/projects/mongrel/
127 3 Jack Kurzecki
128 1 Jack Kurzecki
# Install Mongrel gems
129 9 Jack Kurzecki
#* in command window, execute: <pre>
130 1 Jack Kurzecki
gem install mongrel
131
</pre>
132 9 Jack Kurzecki
#** expected output:<pre>
133 1 Jack Kurzecki
Successfully installed gem_plugin-0.2.3
134
Successfully installed cgi_multipart_eof_fix-2.5.0
135 9 Jack Kurzecki
Successfully installed mongrel-1.1.5-x86-mingw32
136
3 gems installed
137 1 Jack Kurzecki
</pre>
138
139
h3. Install mysql gem
140
141
* _At the time of writing this document the latest version of mysql gem was 2.8.1. Newer versions should work too._
142
* It drastically improves page generation speed.
143
144 3 Jack Kurzecki
# Install mysql gem
145 9 Jack Kurzecki
#* in command window, execute: <pre>
146 1 Jack Kurzecki
gem install mysql
147
</pre>
148 9 Jack Kurzecki
#** expected output:<pre>
149
Successfully installed mysql-2.8.1-x86-mingw32
150
1 gem installed
151
Installing ri documentation for mysql-2.8.1-x86-mingw32...
152
No definition for (...)
153 1 Jack Kurzecki
</pre>
154 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_
155 1 Jack Kurzecki
156
h3. Install mongrel-service + win32-service gems
157
158
* _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_
159
* *Use only win32-service version 0.5.2 for Redmine deployment.*
160
161 9 Jack Kurzecki
# Download *"mongrel_service-0.3.4-i386-mswin32.gem"* from "here":http://rubyforge.org/frs/?group_id=1306
162
# Move *mongrel_service-0.3.4-i386-mswin32.gem* to *C:\webserver\*
163 1 Jack Kurzecki
# Download *"win32-service-0.5.2-mswin32.gem"* from "here":http://files.ruby.inoack.com/win32utils/
164 9 Jack Kurzecki
#* _This file is also attached at the bottom of this wiki page_
165
# Move *win32-service-0.5.2-mswin32.gem* to *C:\webserver\*
166 3 Jack Kurzecki
# Install the gem
167 1 Jack Kurzecki
#* in command window, execute: <pre>
168 9 Jack Kurzecki
cd C:\webserver\
169
gem install mongrel_service
170
</pre>
171
#** expected output:<pre>
172 1 Jack Kurzecki
Successfully installed win32-service-0.5.2-x86-mswin32
173 9 Jack Kurzecki
Successfully installed mongrel_service-0.3.4-x86-mswin32
174 1 Jack Kurzecki
2 gems installed
175
</pre>
176
# Delete the two .gem files from C:\webserver\
177
178 3 Jack Kurzecki
h2. Install Redmine
179 9 Jack Kurzecki
180 11 Jack Kurzecki
* _Procedure below assumes we will be installing Redmine 1.0.4, but it also works with any revisions >= r3235_
181 9 Jack Kurzecki
182 11 Jack Kurzecki
# Download *"redmine-1.0.4.zip"* from "here":http://rubyforge.org/frs/?group_id=1850
183
# Extract the contents of the +redmine-1.0.4+ directory in the archive to *C:\webserver\Redmine*
184 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".
185
## "Open connection to Start Querying"
186 1 Jack Kurzecki
## In SQL Query window enter the following script: <pre>
187
create database redmine character set utf8;
188
create user 'redmineUser'@'localhost' identified by 'myPassword';
189
grant all privileges on redmine.* to 'redmineUser'@'localhost';
190 9 Jack Kurzecki
</pre>
191
## "Execute SQL Script in Connected Server"
192
##* _You should of course change *redmineUser* and *myPassword* to something different._
193
# Copy *C:\webserver\Redmine\config\database.yml.example* to *C:\webserver\Redmine\config\database.yml*
194 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>
195
production:
196
  adapter: mysql
197 9 Jack Kurzecki
  database: redmine
198 1 Jack Kurzecki
  host: localhost
199 9 Jack Kurzecki
  username: redmineUser
200
  password: myPassword
201
  encoding: utf8
202
</pre>
203
## Set username and password to the values entered in the SQL script above.
204
## Save and close the file.
205
# Create (or update) Redmine database tables
206
#* in command window, execute: <pre>
207
cd C:\webserver\Redmine
208
set RAILS_ENV=production
209 1 Jack Kurzecki
rake generate_session_store
210
rake db:migrate
211 9 Jack Kurzecki
</pre>
212
#** _If you encounter this error: *Mysql::Error: query: not connected: CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB*_ :
213
#**# download *libmySQL.dll* from "here":http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/
214
#**# move this .dll file to *C:\webserver\Ruby\bin\*
215
#**# in command window, again execute: <pre>
216
rake db:migrate
217
</pre>
218
# If this is a fresh install, you can pre-populate the tables with default data
219
#* in command window, execute: <pre>
220 1 Jack Kurzecki
rake redmine:load_default_data
221
</pre>
222 9 Jack Kurzecki
# _Assuming that we will be hosting Redmine under http://localhost/redmine_
223
#* 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).
224 1 Jack Kurzecki
#* add the following line at the bottom of the file:<pre>
225
Redmine::Utils::relative_url_root = "/redmine" 
226
</pre>
227
#* save and close the file.
228 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*_
229 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":
230
#*** Create a file config/initializers/patch_for_mongrel.rb  [name of file can be anything]:
231 1 Jack Kurzecki
<pre>
232 3 Jack Kurzecki
# Fix for mongrel which still doesn't know about Rails 2.2's changes, 
233 8 Tiemo Vorschuetz
# We provide a backwards compatible wrapper around the new
234
# ActionController::base.relative_url_root,
235
# so it can still be called off of the actually non-existing
236
# AbstractRequest class.
237
238
module ActionController
239
  class AbstractRequest < ActionController::Request
240
    def self.relative_url_root=(path)
241
      ActionController::Base.relative_url_root=(path)
242
    end
243
    def self.relative_url_root
244
      ActionController::Base.relative_url_root
245
    end
246
  end
247
end
248
#
249
# Thanks to http://www.ruby-forum.com/topic/190287
250
</pre>
251
252
h2. Setup windows services
253
254
* 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:
255 1 Jack Kurzecki
** Apache = 5MB + 20MB + 40MB = 65MB
256
** MySQL = 35MB
257 3 Jack Kurzecki
** Mongrel cluster = number-of-mongrel_rails-services x (3MB + 90MB) = 279MB (@3 processes)
258
259
# Create windows services
260 9 Jack Kurzecki
## in command window, execute: <pre>
261
mongrel_rails service::install -N mongrel_redmine_3001 -D "Mongrel serving Redmine on 3001" -p 3001 -e production -c C:\webserver\Redmine
262
mongrel_rails service::install -N mongrel_redmine_3002 -D "Mongrel serving Redmine on 3002" -p 3002 -e production -c C:\webserver\Redmine
263 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
264
</pre>
265
# Start windows services, which in turn will start mongrel servers
266
## in command window, execute: <pre>
267
net start mongrel_redmine_3001
268
net start mongrel_redmine_3002
269
net start mongrel_redmine_3003
270 2 Jack Kurzecki
</pre>
271
# Go to the Windows Services list and set all "Mongrel serving Redmine on 300#" services to start automatically
272 1 Jack Kurzecki
## in command window, execute: <pre>
273
services.msc /s
274 2 Jack Kurzecki
</pre>
275 1 Jack Kurzecki
## find each one of "Mongrel serving Redmine on 300#" services
276
## right click, select *Properties*
277
## set *Startup type* to *"Automatic"*
278 10 Jozef Izso
## press OK and repeat for the remaining Mongrel services.
279
#* _Alternatively you can execute this command on elevated command prompt for each mongrel service installed:_ <pre>
280
sc config mongrel_redmine_3001 start= auto
281 3 Jack Kurzecki
</pre>
282
283
h2. Configure Apache 2.2.x as proxy to Mongrel cluster
284
285 1 Jack Kurzecki
* _Procedure below assumes we will be hosting Redmine under http://localhost/redmine and must match the *relative_url_root* set above_
286 9 Jack Kurzecki
287 1 Jack Kurzecki
# Open *C:\webserver\Apache\conf\httpd.conf*
288 3 Jack Kurzecki
# At the bottom of this file add the following line: <pre>
289 1 Jack Kurzecki
Include conf/httpd-proxy-mongrel.conf
290 9 Jack Kurzecki
</pre>
291 1 Jack Kurzecki
# Create a file *C:\webserver\Apache\conf\httpd-proxy-mongrel.conf*
292 9 Jack Kurzecki
# Enter the following: <pre>
293
<IfModule !mod_proxy.c>
294
	LoadModule proxy_module modules/mod_proxy.so
295
</IfModule>
296
<IfModule !mod_proxy_http.c>
297
	LoadModule proxy_http_module modules/mod_proxy_http.so
298
</IfModule>
299
<IfModule !mod_proxy_balancer.c>
300
	LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
301 1 Jack Kurzecki
</IfModule>
302
303
ProxyPass /redmine balancer://redmine_cluster
304
ProxyPassReverse /redmine balancer://redmine_cluster
305
306 9 Jack Kurzecki
<Proxy balancer://redmine_cluster>
307
    BalancerMember http://127.0.0.1:3001
308
    BalancerMember http://127.0.0.1:3002
309 1 Jack Kurzecki
    BalancerMember http://127.0.0.1:3003
310 3 Jack Kurzecki
</Proxy>
311
</pre>
312
# Restart the Apache service.
313 9 Jack Kurzecki
#* in command window, execute: <pre>
314
C:\webserver\Apache\bin\httpd.exe -w -n "Apache2.2" -k stop
315 1 Jack Kurzecki
C:\webserver\Apache\bin\httpd.exe -w -n "Apache2.2" -k start
316
</pre>
317
318 2 Jack Kurzecki
319
320 9 Jack Kurzecki
*+DONE!+*
321 2 Jack Kurzecki
Your local installation of Redmine is now accessible at http://localhost/redmine
322 9 Jack Kurzecki
323 3 Jack Kurzecki
324 9 Jack Kurzecki
h2. Additional components
325 1 Jack Kurzecki
326
h3. Install RMagic
327 9 Jack Kurzecki
328
# 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
329
# Extract *"rmagick-2.12.0-x86-mswin32.gem"* to *C:\webserver\*
330
# Install *"ImageMagick-6.5.6-8-Q8-windows-dll.exe"* to *C:\webserver\ImageMagick*
331
# Install the RMagic gem
332
#* in command window, execute: <pre>
333
cd C:\webserver
334 1 Jack Kurzecki
gem install rmagick --local
335 9 Jack Kurzecki
</pre>
336
#** expected output:<pre>
337
Successfully installed rmagick-2.12.0-x86-mswin32
338 1 Jack Kurzecki
1 gem installed
339 9 Jack Kurzecki
</pre>
340
# Delete the .gem file from C:\webserver\
341 1 Jack Kurzecki
# Reboot your server. (I was unsuccessful trying to get it to work without rebooting)
342 9 Jack Kurzecki
343
344
h3. Add redmine_attach_screenshot plugin
345
346 11 Jack Kurzecki
# download source from "here":https://github.com/blondak/redmine_attach_screenshot
347 9 Jack Kurzecki
# Extract the archive to *C:\webserver\Redmine\vendor\plugins\redmine_attach_screenshot*
348
# Restart the Mongrel cluster
349
#* in command window, execute: <pre>
350
net stop mongrel_redmine_3001
351
net stop mongrel_redmine_3002
352
net stop mongrel_redmine_3003
353
net start mongrel_redmine_3001
354
net start mongrel_redmine_3002
355
net start mongrel_redmine_3003
356
</pre>
357
358
359
360 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+