2010年3月28日 星期日

HOWTO: Install Subversion, Ruby on Rails and Redmine on CentOS5 (& RHEL5)

This HOWTO is written for CentOS 5.2 [updates for 5.3 in purple text]
Replace [FQDN] with either your IP address or the hostname (or FQDN) which you’ll be using to access the interface.
Replace [user] with the username under whom’s home directory the Subversion repository database will be located. e.g. /home/[user]/svn-repos
This HOWTO will be using the following variables:
You already have the “httpd” (apache) package installed
You will be running apache as the user ‘apache’
The subversion repository root folder will be under /home/[user]/subversion/
The vhost’s folder locationg will be /var/www/svn
The subversion repository to be created will be called ‘example-repo’
Install and set up Subversion

1
yum install mod_dav_svn subversion
Add the group [user] to the user apache and make the subversion base URL readable and writable…

1
usermod -aG [user] apache
2
chmod g+x /home/[user]
3
mkdir /home/[user]/subversion
4
chmod g+rwx /home/[user]/subversion
5
chown -R [user]:[user] /home/[user]/subversion
Make the web directory:

1
mkdir /var/www/svn
2
chown apache.apache /var/www/svn
Put the following into /etc/httpd/conf.d/svn.conf (this is for a sub-repo called ‘example-repo’)

01
NameVirtualHost *:80
02

03
DocumentRoot "/var/www/svn"
04
ServerName [FQDN]
05

06
DAV svn
07
SVNPath /home/[user]/subversion/example-repo
08
AuthType Basic
09
AuthName "Subversion repo"
10
AuthUserFile /var/www/passwd
11
Require valid-user
12

13

14

15
allow from all
16
Options +Indexes
17

18

Add an HTTP auth user…

1
htpasswd -cm /var/www/passwd [user]
Create a proper SVN repository

1
cd /home/[user]/subversion
2
su [user] -c "svnadmin create example-repo"
Import any SVN repos by doing:

1
su [user] -c "svnadmin load example-repo < /path/to/repo/dump/file"
Make sure the permissions are correct

1
chmod g+rwx /home/[user]/subversion
2
chown -R [user].[user] /home/[user]
Install Ruby on Rails

*NOTE: Ruby on Rails installation requires the EPEL yum repository (at time of writing).

1
su -c 'rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm'
Let’s get Ruby up and running first… [NOTE: not on an SElinux environment cba with that]

1
yum install httpd httpd-devel apr make gcc-c++ mysql-server mysql ruby ruby-devel ruby-docs ruby-ri \
2
ruby-libs ruby-mode ruby-tcltk ruby-irb ruby-rdoc fcgi fcgi-devel mod_fcgid rubygems subversion-ruby
Now we’ll install passenger (aka mod_rails)

1
gem install passenger
2
passenger-install-apache2-module
Create and insert this text into /etc/httpd/conf.d/rails.conf (or alternatively edit the existing svn.conf created when we set up subversion)
NOTE:

The below configuration is specific to the installation of redmine (hence the DocumentRoot)
01
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
02
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6
03
PassengerRuby /usr/bin/ruby
04

05
NameVirtualHost *:80
06

07

08
ServerName 192.168.10.17
09
DocumentRoot /var/www/rails/redmine/public
10

Now on to Redmine itself

Get Redmine 0.8 from http://www.redmine.org/wiki/redmine/Download

1
cd /usr/src
2
svn co http://redmine.rubyforge.org/svn/branches/0.8-stable redmine-0.8
3
mkdir /var/www/rails/
4
cd /var/www/rails/
5
cp -r /usr/src/redmine-0.8/ redmine/
6
chown -R apache.apache redmine
7
cd redmine
Create a clean backup of source files

1
tar czf Redmine0.8-clean.tar.gz .
Initialise mySQL:

1
service mysqld start
To secure mysql:

1
mysql_secure_installation
Create a mysql database for redmine…

1
mysql -u[username] -p
At the prompt enter:

1
create database redmine character set utf8;
Quit with:

1
quit
Copy the example database file to the “live” location

1
cd /var/www/rails/redmine
2
cp config/database.yml.example config/database.yml
Enter the appropriate settings for the [production] section ensuring that host is set to 127.0.0.1

1
vim /var/www/rails/redmine/config/database.yml
Set up email

1
cd /var/www/rails/redmine
2
cp config/email.yml.example config/email.yml
Enter the appropriate settings for the [production] section ensuring that “address” is set to the IP address of the SMTP host

1
vim /var/www/rails/redmine/config/email.yml
Install rails for redmine using gem…

1
cd /var/www/rails/redmine/app/
2
gem install -v=2.1.2 rails
Import the redmine database into the live database specified in the above config file

1
cd /var/www/rails/redmine/app/
2
rake db:migrate RAILS_ENV="production"
Install default configuration data in database (this is entirely optional, but recommended).

1
cd /var/www/rails/redmine/app/
2
rake redmine:load_default_data RAILS_ENV="production"
Bring up the testing webserver, once loaded check your config by browsing to http://[FQDN]:3000

1
cd /var/www/rails/redmine/
2
ruby script/server -e production
Make sure your apache config file edits are ok and that the services will start at boot by doing:

1
service httpd configtest
2
service httpd restart
3
chkconfig httpd on
4
chkconfig mysqld on
[Optional:] Add the following to your crontab which will create a database backup in the /home/[user] directory

1
/usr/bin/mysqldump -u -p | gzip > /home/[user]/redmine_`date +%y_%m_%d`.gz
Make your subversion server configuration accessible to redmine by doing the following:

1
mkdir /etc/subversion
2
cp -r /root/.subversion/* /etc/subversion/
3
vim /var/www/rails/redmine/lib/redmine/scm/adapters/subversion_adapter.rb
Change the line:

1
SVN_BIN = "svn"
to:

1
SVN_BIN = "svn --config-dir /etc/subversion"
Then restart apache:

1
service httpd restart


摘自:http://blog.itsmine.co.uk/2009/01/22/howto-install-subversion-and-redmine-on-centos5-rhel5/

沒有留言:

wibiya widget