Redmine Trac and EHCP How To in Ubuntu 10.04

First:
Step 1: Install Redmine
Once you have a functioning Ubuntu operating system up and running, you can continue with installing Redmine.

Install dependencies
The following packages are required to install and run Redmine. Please install them by running apt-get as root:

sudo apt-get package-name

where package-name is each of:
apache2
apache2-threaded-dev
build-essential
libapache-dbi-perl
libapache2-mod-perl2
libapache2-svn
libdigest-sha1-perl
libgemplugin-ruby
libgemplugin-ruby1.8
libruby-extras
libruby1.8-extras
mongrel
mysql-server
rails
rake
ruby
rubygems
rubygems1.8
ruby1.8-dev
subversion

Step 2:

Create a domain in EHCP
Login in modo root and make: sudo su
go to the directory apache pf your domain.
Normally is:
/var/www/vhosts/Your_USER/Your_Domain/httpdocs

Get the version you like of redmine in:
ejemplo: http://rubyforge.org/frs/download.php/66633/redmine-0.8.6.tar.gz
or visit:
http://www.redmine.org/
make: tar -xvf redmine-0.8.6.tar.gz or tar -xvf the redmine-version-you-choice

Database Setup:

1.Now it’s time to create an empty database for Redmine. As you may have noticed, we installed phpMyAdmin earlier. phpMyAdmin will come in handy now. Head over to http://localhost/phpmyadmin. You should be presented with the phpMyAdmin login screen.
Type in “root” and the MySQL “password” you created when installing MySQL.

2.First, click on “Databases” Then, at the bottom of the screen, in the “Create new database” text box create a new database called “redmine” and set “Collation” to “utf8_general_ci”.

3.Now, go back to the home screen and click on:
“Privileges”
“Add a new User”
Fill out the “Login Information” boxes. Call your user “redmine” or better any other name you like. Make sure you remember password you create here. It will be used when you set up the database connection details in Redmine.
In the “Database for user” section, check “Create database with same name and grant all privileges” and click on the “Go” button.

4.Log out of phpMyAdmin.

Redmine Database Connection Configuration:

1.It’s time to configure the database connection. If you installed Redmine as I did above, then copy “config/database.yml.example” to “config/database.yml” and edit this file in order to configure your database settings for “production” environment. You’ll find the “database.yml.example” issuing:

sudo cd /opt/redmine/redmine-0.8.6/config

2.So now, assuming you’re in the “/httpdocs/config” directory, issue:

sudo cp database.yml.example database.yml

3.Then, open the “database.yml” file, issue:

sudo gedit database.yml
… and edit it as in the example for a MySQL database below:

production:
adapter: mysql
socket: /var/run/mysqld/mysqld.sock
database: redmine
host: localhost
username: redmine
password: [password]

Then save “database.yml” file and exit to the command prompt.
On Ubuntu the “mysql.sock” is located in /var/run/mysqld/mysqld.sock, as noted in the “config” above.
(The standard Redmine installation assumes the socket is located in “/opt/redmine/redmine-0.8.6/tmp/mysqld.sock”.)

4.Create the database structure, by running the following command under the application root directory(I mean “/opt/redmine/redmine-0.8.6”):

sudo rake db:migrate RAILS_ENV="production"
It will create the necessary tables in the redmine database you created earlier and an administrator account.

5.Insert default configuration data in database, by issuing:

sudo rake redmine:load_default_data RAILS_ENV="production"
(This step is optional but highly recommended, as you can define your own configuration from scratch. It will load default roles, trackers, statuses, work flows and enumerations. While loading default data command prompt wants to given language selection by you.)

Setting up Permissions:

1.The user who runs Redmine must have write permission on the following sub directories: “files”, “log”, “tmp” (create the last one if not present). You probably already have a “tmp” directory in .../httpdocs, but if you don’t, create one now by issuing:

3.Now, assuming you go to to use your vsftpd user, from your .../httpdocs directory issue:

sudo chown -R vsftpd:www-data files log tmp sudo chmod -R 755 files log tmp

Testing the Installation:

1.It should all be working now. Test the installation by running the WEBrick web server issue:

sudo cd /opt/redmine/redmine-0.8.6 sudo ruby script/server -e production

Once WEBrick has started, point your browser to http://localhost:3000/. Or, if you are using a browser on another computer than what you installed Redmine on, point your browser to http://192.168.1.10:3000/ (if that’s the IP address you gave your Redmine server). You should now see the application welcome page.

Log in:

1.Use default administrator account to log in:
Login : admin
Password : admin

2.You can go to Admin & Settings to modify application settings.

Configuring the Passenger Apache module
Passenger is a module for apache2 that allow apache to run ruby on rails applications. Install it thus:

$ sudo gem install passenger

Then go to the passenger apache2 module installation directory and run passenger-install-apache2-module

$ cd /var/lib/gems/1.X/gems/passenger-X.X.X/

$ sudo bin/passenger-install-apache2-module

Next, configure Apache:

In /etc/apache2/mods-available/passenger.load we will add next line

LoadModule passenger_module /var/lib/gems/1.X/gems/passenger-X.X.X/ext/apache2/mod_passenger.so

We have to edit the conf of the passenger apache2 module in /etc/apache2/mods-available/passenger.conf

PassengerRoot /var/lib/gems/1.X/gems/passenger-X.X.X PassengerRuby /usr/bin/ruby1.X

And now we active the module

$ sudo a2enmod passenger

Apache virtualhost for redmine web app
Here is very important for work
First go to the directory public and make:
gedit .htaccess
Delete all the code and change for that:
# General Apache options for EHCP by Gineta

AddHandler cgi-script .cgi

Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteBase /httpdocs
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

ErrorDocument 500 "Application errorRails application failed to start properly"

SAVE THE DOCUMENT

Make again inside the directory public:
gedit dispatch.fcgi.example if you have FAST CGI
and make like this:
#!/usr/bin/env ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# and the GC period is nil (turned off). A reasonable number of requests
# could range from 10-100 depending on the memory footprint of your app.
#
# Example:
# # Default log path, normal GC behavior.
# RailsFCGIHandler.process!
#
# # Default log path, 50 requests between GC.
# RailsFCGIHandler.process! nil, 50
#
# # Custom log path, normal GC behavior.
# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
#
require File.dirname(__FILE__) + "/../config/environment"
require 'fcgi_handler'

RailsFCGIHandler.process!

NOW MAKE SAVE LIKE: dispatch.fcgi

If you LIKE to use normal CGI
OPEN: gedit dispatch.cgi.example
and make is like this:
#!/usr/bin/ruby

require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)

require "dispatcher"

ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch

OK NOW WE GO TO EHCP CONTROL PANEL
we go to the domain and here look not make any error.

1.- Click edit apache template for this domain
2.- We look for the lines:

ServerName {domainname}
ServerAlias www.{domainname}
# buraya aliaslar yazilacak..
WE ADD AFTER THE NEXT:
PassengerAppRoot /var/www/vhosts/YOUR USERNAME/YOUR DOMAIN/httpdocs/
RailsBaseURI {homedir}/httpdocs/public
Alias /httpdocs /var/www/vhosts/YOURUSERNAME/YOURDOMAIN/httpdocs/public/

Change your username for the username of this domain and yourdomain for teh domain name Please :)

WE LOOK AFTER where SAY
{aliases}

UseCanonicalName Off
and we change the lines after like THAT:
DocumentRoot {homedir}/httpdocs/public
ScriptAlias /cgi-bin/ {homedir}/httpdocs/public/cgi-bin/

NOW WE LOOK DOWN AND WHERE SAY:

we add after the next:
Options ExecCGI FollowSymLinks
AddHandler cgi-script .cgi .pl
AllowOverride all
Order allow,deny
Allow from all
RewriteEngine On

NOW IS ALL HERE AND WE CLICK IN SUBMIT

NOW WE GO TO CUSTOM HTTP
and we ADD A NEW CUSTOM HTTP
LogLevel warn
ErrorLog /var/log/apache2/redmine_error
CustomLog /var/log/apache2/redmine_access combined

NOW YOUR SERVER NEED TO OPEN REDMINE IN YOUR DOMAIN
TRY
:))

Comments

for programmers:

all programmers, can you work on this for automating ?
using php or python script..
should be installable like "easy install scripts" in ehcp.

I can try to see if I can make.
I go to see first the system of your easy install script and try to make a installer

I see few errors in the post. I make the rectifications in http://www.wiki.elistas.org/?p=20
In few days I post also how make redmine in ehcp control subversion
And at the end I go to make a simple script for automatic installation

hi, i read roughly your post at elistas.org,

Thank you for this nice tut.
I want to remind one point:
database setup should be through ehcp gui (or ehcp api), i think,
because otherwise, database which is setup using phpmyadmin is not controlled in ehcp, and not seen in ehcp gui, nor deletable.

This is a very useful tutorial.I have been struggling to install EHCP in Ubuntu for last 2 months.Finally after going through the tutorial,I was able to install the EHCP.I was making a small error while installing,after login with my admin account I was not changing changing the settings to modify the application,hence I was getting the error.Hopefully many users like me who are struggling to install it in Ubuntu will see this tutorial and succeed.