Project

General

Profile

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

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