h1. Installing Redmine using an existing redmine DB + MySQL on CentOS 5 {{>toc}} h2. Requirements: * Ruby 1.8.7 * MySQL 4.1 or higher (recommended) * openssl + openssl-devel * zlib + zlib-devel * Lighttpd * fastcgi * RubyGems > # actionmailer (2.3.5) > # actionpack (2.3.5) > # activerecord (2.3.5) > # activeresource (2.3.5) > # activesupport (2.3.5) > # cgi_multipart_eof_fix (2.5.0) > # daemons (1.0.10) > # fastthread (1.0.7) > # fcgi (0.8.8) > # gem_plugin (0.2.3) > # mongrel (1.1.5) > # mysql (2.8.1) > # rack (1.0.1) > # rails (2.3.5) > # rake (0.8.7) > # rmagick (2.0.0) Lets install all required packages before compiling ruby. h2. Add rpmforge to depots
    yum install wget
    rpm –import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
    wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
    rpm -ihv rpmforge-release-0.3.6-1.el5.rf.i386.rpm
Now we will have the latest software that is not updated on official repos. h2. Installing all required software from repos:
    yum install gcc-c++ mysql-server mysql-devel openssl openssl-devel zlib zlib-devel subversion make
h2. Start mysql server and change the pasword for user root in mysql (by default its empty):
    service mysqld start
    mysqladmin -u root password newpassword
    chkconfig mysqld on
Now we should be ready for ruby installation. h2. Installing Ruby:
    wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.tar.gz
    tar zxvf ruby-1.8.7.tar.gz
    cd ruby-1.8.7
    ./configure
    make && make install
h2. Installing RubyGems:
    wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
    tar zxvf rubygems-1.3.5.tgz
    cd rubygems-1.3.5
    ruby setup.rb
h2. Installing Rails:
    gem install rails -v=2.3.5
h2. Installing Redmine:
    useradd -M redmine  # doesn't create home directory

    cd /opt
    svn co http://redmine.rubyforge.org/svn/trunk redmine
    mkdir /opt/redmine/public/plugin_assets
    chown -R redmine:redmine /opt/redmine/public/plugin_assets
    cd redmine
    chown -R redmine:redmine files log tmp
    chmod -R 755 files log tmp
h2. Create Database and give access rights
mysql -u root -p
create database redmine character set utf8;
create user 'redmine'@'localhost' identified by 'my_password';
grant all privileges on redmine.* to 'redmine'@'localhost';
h2. Migrate configuration files:
    cp /opt/redmine/config/database.yml.example /opt/redmine/config/database.yml

    # /opt/redmine/config/database.yml
    production:
	  adapter: mysql
	  database: redmine
	  host: localhost
	  username: redmine
	  password: mysql_password
	  encoding: utf8

    cp /opt/redmine/config/email.yml.example /opt/redmine/config/email.yml

    # /opt/redmine/config/email.yml
    production:
	  delivery_method: :smtp
	  smtp_settings:
	    address: 127.0.0.1
	    port: 25
	    domain: mail_server_domain
	    authentication: :none



h2. Generate a session store secret:
    cd /opt/redmine
    rake config/initializers/session_store.rb
h2. Migrate or Install Database :
	gem install mysql
	On projects : mysqldump --single-transaction --add-drop-table -u root -p redmine | gzip -9 > redmine.sql.gz
	On new redmine : 
		gunzip redmine.sql.gz
		mysql -u root -p redmine < redmine.sql

	# upgrade the migrated database for the new version	
	RAILS_ENV=production rake db:migrate
	# you will now see the upgrades appear on the screen
        # IF INSTALLING FOR FIRST TIME USE
        RAILS_ENV=production rake redmine:load_default_data

h2. Migrate Files if there are any :
	On projects : cd /opt/redmine/files
	tar -czf /root/files.tar.gz /opt/redmine/files/*
	On new redmine :
		cp /root/migration/files.tar.gz /opt/redmine/files/		
		tar -zxvf files.tar.gz
h2. Test Server : h3. On new redmine :
	cd /opt/redmine
	ruby script/server webrick -p 8000 -e production
h3. on a local machine
	http://redmine_server_ip_address:8000/
	Login with your current redmine identification, the ldap is already installed

        # Configure ldap authentication
        Administration 
        LDAP Authentication
        New authentication mode
        Name ldap_ServerName
        Host ldap_server_ip_address
        Port 389
        Account cn=ldapuser,o=ldapOrganization
        Password xxxxxxxxxxxx
        Base DN o=ldapOrganization
        On-the-fly user creation  # check this if you want users to be added to redmine when the user logs in, check this



	On new redmine :
	Stop webrick with CTRL-C
h2. Install lighttpd h3. Install packages from Centos
	
yum install lighttpd lighttpd-fastcgi php-cli

vi /etc/php.ini
	[...]
	cgi.fix_pathinfo = 1
h3. Install FastCGI Gem
cd /tmp
wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar -zxvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure --prefix=/usr/local/fcgi --exec-prefix=/usr/local/fcgi
make
make install

gem install fcgi -r -- --with-fcgi-lib=/usr/local/fcgi/lib --with-fcgi-include=/usr/local/fcgi/include

h3. Set Permissions & Create Log Directories
chown redmine:redmine -R /var/log/lighttpd
mkdir /var/log/redmine
chown redmine:redmine -R /var/log/redmine
h3. Enable dispatch.fgci
cd /opt/redmine
cp dispatch.fcgi.example dispatch.fcgi
chown redmine:redmine -R /opt/redmine/public/plugin_assets
h2. Lighttpd vhost
$HTTP["host"] =~ "redmine\.somecompany\.(eu|fr|net|com)$" {
        server.document-root = "/opt/redmine/public/"
        server.use-ipv6 = "disable"
        fastcgi.debug = 1
        alias.url = ()
        server.indexfiles = ( "dispatch.fcgi" )
        server.error-handler-404 = "/dispatch.fcgi"
        server.errorlog          = "/var/log/redmine/redmine-error.log"
        accesslog.filename       = "/var/log/redmine/redmine-access.log"
        server.follow-symlink    = "enable"
        
        url.rewrite-once = (
                "^/(.*\..+(?!html))$" => "$0",
                "^/(.*)\.(.*)"        => "$0",
        )
        
        fastcgi.server = ( 
                ".fcgi" => ( "redmine" => (     
                        "socket"                => "/opt/redmine/tmp/sockets/redmine.socket",
                        "bin-path"              => "/usr/local/bin/ruby /opt/redmine/public/dispatch.fcgi",
                        "min-procs" => 1,
                        "max-procs" => 4, 
                        "idle-timeout" => 120,
                        "check-local" => "disable",
                        "bin-environment" => ( "RAILS_ENV" => "production" ),
                ))
        )
}
h2. Test the lighttpd configuration

[root@projects ~]# lighttpd -t -f /etc/lighttpd/lighttpd.conf
Syntax OK

h2. Install the init script
cp /etc/init.d/lighttpd /etc/init.d/redmine
chkconfig redmine on
h2. Start the redmine server /etc/init.d/redmine start h2. Install ImageMagick
	yum install tcl-devel libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel
	cd /root/source
	wget http://image_magick.veidrodis.com/image_magick/ImageMagick-6.3.2-9.tar.gz
	
	tar -zxvf ImageMagick-6.3.2-9.tar.gz 
	cd ImageMagick-6.3.2
	./configure  --prefix=/usr/local --with-bzlib=yes --with-fontconfig=yes --with-freetype=yes --with-gslib=yes 
           --with-gvc=yes --with-jpeg=yes --with-jp2=yes --with-png=yes --with-tiff=yes
	make clean
	make 
	make install
	gem install rmagick -v=2.0 --no-rdoc --no-ri
h2. Install the redmine basecamp theme
    mkdir /opt/redmine.old/public/themes/basecamp
    mv basecamp.tar.gz basecamp
    cd /opt/redmine.old/public/themes/basecamp/
    tar -zxvf basecamp.tar.gz 
    mkdir -p /opt/redmine/public/themes/basecamp
    cp -Rp stylesheets /opt/redmine/public/themes/basecamp/
h2. Install postfix
	yum install postfix
	/etc/postfix/main.cf
	relayhost = smtp_server_address:smtp port
	chkconfig postfix on
	/etc/init.d/postfix start
	Add the public address as a host in the networks table on proxmox