HowTo configure Apache to run Redmine » History » Version 4

Cyber Sprocket, 2009-06-02 07:07

1 1 Cyber Sprocket
h1. HowTo configure Apache to run Redmine
2 1 Cyber Sprocket
3 2 Cyber Sprocket
{{toc}}
4 1 Cyber Sprocket
5 2 Cyber Sprocket
These notes assume you already have Redmine running via the webrick server and are looking to get Redmine running via your existing Apache installation.   Most of the commands assume you are in the root installation directory of redmine, so be sure to change directory there before starting.
6 1 Cyber Sprocket
7 1 Cyber Sprocket
h2. For CentOS 5
8 1 Cyber Sprocket
9 1 Cyber Sprocket
h3. Assumptions
10 1 Cyber Sprocket
11 1 Cyber Sprocket
* OS is CentOS 5
12 1 Cyber Sprocket
* Web server is Apache 2
13 1 Cyber Sprocket
** mod_cgi is enabled
14 1 Cyber Sprocket
** name based virtual servers are being used
15 2 Cyber Sprocket
** the web server runs under the user apache, group apache
16 1 Cyber Sprocket
17 4 Cyber Sprocket
h3. Myths
18 4 Cyber Sprocket
19 4 Cyber Sprocket
* You do not need to run mod_fcgid
20 4 Cyber Sprocket
* You do not need to run mod_fastcgi
21 4 Cyber Sprocket
* You 
22 4 Cyber Sprocket
23 1 Cyber Sprocket
h3. Basic Steps
24 1 Cyber Sprocket
25 1 Cyber Sprocket
* Install Redmine per the installation instructions and get it running with webrick.
26 1 Cyber Sprocket
27 1 Cyber Sprocket
* Kill the webrick session
28 1 Cyber Sprocket
29 1 Cyber Sprocket
* Copy the public/dispatch.cgi.example to public/dispatch.cgi
30 1 Cyber Sprocket
31 1 Cyber Sprocket
* Edit public/dispatch.cgi to fix the shell script invocation to read:
32 1 Cyber Sprocket
  @#!/usr/local/bin/ruby@
33 1 Cyber Sprocket
34 1 Cyber Sprocket
* Make sure public/dispatch.cgi has execute permissions via:
35 1 Cyber Sprocket
  @# chmod 755 public/dispatch.cgi@
36 1 Cyber Sprocket
37 1 Cyber Sprocket
* Update the config/environment.rb file to force the rails environment to production, simply uncomment this line at the start of the file:
38 1 Cyber Sprocket
  @ENV['RAILS_ENV'] ||= 'production'@
39 1 Cyber Sprocket
40 3 Cyber Sprocket
* Add your virtual host entry to the apache configuration file (/etc/httpd/conf/httpd.conf).  We installed redmine into the /live/redmine folder on our server. _Note: be sure to point your DocumentRoot to the public sub-folder!_
41 3 Cyber Sprocket
42 1 Cyber Sprocket
<pre>
43 1 Cyber Sprocket
    <VirtualHost *:80>
44 1 Cyber Sprocket
        ServerName redmine.<YOUR-DOMAIN>.com
45 1 Cyber Sprocket
        ServerAdmin webmaster@<YOUR-DOMAIN>.com
46 1 Cyber Sprocket
        DocumentRoot /live/redmine/public/
47 1 Cyber Sprocket
        ErrorLog logs/redmine_error_log
48 1 Cyber Sprocket
49 1 Cyber Sprocket
        <Directory "/live/redmine/public/">
50 1 Cyber Sprocket
                Options Indexes ExecCGI FollowSymLinks
51 1 Cyber Sprocket
                Order allow,deny
52 1 Cyber Sprocket
                Allow from all
53 1 Cyber Sprocket
                AllowOverride all
54 1 Cyber Sprocket
        </Directory>
55 1 Cyber Sprocket
    </VirtualHost>
56 1 Cyber Sprocket
</pre>
57 1 Cyber Sprocket
58 1 Cyber Sprocket
* Make sure your files, log, tmp, and vendor directories are all accessible (read/write) by user apache, group apache. We did that via a change of ownership:
59 1 Cyber Sprocket
  @# chown -R apache:apache files log tmp vendor@
60 1 Cyber Sprocket
61 1 Cyber Sprocket
62 2 Cyber Sprocket
h3. Error Messages and Resolutions
63 1 Cyber Sprocket
64 2 Cyber Sprocket
  * @Rails requires RubyGems >= 0.9.4. Please install RubyGems@
65 2 Cyber Sprocket
    Look for rogue versions of ruby binaries.  We had an older version in /usr/bin/ruby as well as /usr/local/bin/ruby.
66 1 Cyber Sprocket
67 2 Cyber Sprocket
  * @Premature script headers@
68 2 Cyber Sprocket
    This is the generic "got something before the Content-Type: header in a CGI script" error from Apache.  Run dispatch.cgi (see below) and see what comes out BEFORE the Content-Type: directive.
69 2 Cyber Sprocket
70 2 Cyber Sprocket
h2. Helpful Commands
71 2 Cyber Sprocket
72 2 Cyber Sprocket
 * @# which ruby@
73 2 Cyber Sprocket
   tells you which ruby binary is being run when the fully-qualified-filename has not been specified.
74 2 Cyber Sprocket
75 2 Cyber Sprocket
 * @# find / -name ruby@
76 2 Cyber Sprocket
   searches your entire system for any file named ruby, warning: can take a while on large filesystems.
77 2 Cyber Sprocket
 
78 2 Cyber Sprocket
 * @# ruby -v@
79 2 Cyber Sprocket
   tell you what version of ruby you are running by default
80 2 Cyber Sprocket
81 2 Cyber Sprocket
 * @#public/dispatch.cgi@
82 2 Cyber Sprocket
   runs the dispatch CGI script.   It should spit out HTML that start with @Content-Type: text/html; charset=utf-8@, if ANYTHING precedes the Content-Type text you will get a "premature script headers" error in the Apache log files.