Install Gitorious on Centos 6
- From the sandbox
- Tutorial

Gitorious - an open source alternative to GitHUB, written in RoR, uses ActiveMQ (in this case Stomp)
Installation was performed on a freshly installed CentOS-6.2-x86_64-minimal distribution. All commands are executed from root, where another user is needed, there will be an appropriate indication.
Installation time ~ 3 hours
Preparation for installation Gitorious
For convenience, I installed the console text editor nano (I do not like vi), the wget rocker, the file manager midnight commander
yum install nano wget mc
Now you need to add the RPMForge repository
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
Then update the system and install some required packages.
yum update
yum groupinstall -y "Development tools" "Development Libraries"
yum install -y git-core git-svn java-1.6.0-openjdk vim-* apg pcre pcre-devel zlib zlib-devel libyaml-devel GeoIP-devel sphinx mysql-devel mysql-server mysql readline-devel libxml2-devel libxslt libxslt-devel aspell*
MySQL
Now configure MySQL
service mysqld start
/usr/bin/mysql_secure_installation
We set the password for the root user and answer yes to all
Ruby Enterprise Edition requests.
Download the latest ruby enterprise distribution from www.rubyenterpriseedition.com/download.html and install
wget http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2012.02.tar.gz
tar xzf tar xzf ruby-enterprise-1.8.7-2012.02.tar.gz
cd cd ruby-enterprise-1.8.7-2012.02
./installer
Press Enter 2 times and wait for the installation to finish
Configure ruby and change the environment variables
cd /opt
ln -s ruby-enterprise-1.8.7-2012.02/ ruby
nano /etc/profile
Добавляем следующие настройки после строки if [ "$EUID" = "0" ]; then
pathmunge /opt/ruby/bin
export RAILS_ENV=production
export PATH=/usr/local/sphinx/bin:/usr/local/bin:$PATH
export _JAVA_OPTIONS=-Xmx64m
export MAGICK_HOME=/usr/local
export DYLD_LIBRARY_PATH=/usr/local/lib
Add the following settings to the very end of the file.
nano /etc/bashrc
pathmungea () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
pathmungea /opt/ruby/bin
export RAILS_ENV=production
export PATH=/usr/local/sphinx/bin:/usr/local/bin:$PATH
export _JAVA_OPTIONS=-Xmx64m
export MAGICK_HOME=/usr/local
export DYLD_LIBRARY_PATH=/usr/local/lib
unset pathmungea
Now log in and proceed with the installation of ImageMagick
ImageMagick
cd ~
yum install -y tcl-devel libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel
in yum, an outdated version of ImageMagick, so install from source to prevent errors
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.7.6-1.tar.gz
tar xzf ImageMagick-6.7.6-1.tar.gz
cd ImageMagick-6.7.6-1
./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
make install
Now you need to install some ruby gems and bundle exec
gem install bundle
gem install sphinx rmagick ultrasphinx mime-types chronic ruby-hmac daemons mime-types BlueCloth ruby-yadis ruby-openid rspec rspec-rails RedCloth stompserver --no-ri --no-rdoc
Add EPEL repository (download.fedora.redhat.com has changed to dl.fedoraproject.org)
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
Gitorious
Actually with the preparation finished, now you can safely proceed to install the subject.
useradd -d / home / git git
su git
cd ~
mkdir log
mkdir conf
git clone git://gitorious.org/gitorious/mainline.git gitorious
cd gitorious/
mkdir -p tmp/pids
exit
#logout в root
ln -s /home/git/gitorious/script/gitorious /usr/local/bin/gitorious
cd /home/git/gitorious/
chmod ug+x script/*
chmod -R g+w config/ log/ public/ tmp/
Configuring gitorious
su git
nano /home/git/gitorious/doc/templates/centos/git-daemon
RUBY_HOME="/opt/ruby"
GITORIOUS_HOME="/home/git/gitorious"
nano /home/git/gitorious/doc/templates/centos/git-ultrasphinx
GITORIOUS_HOME="/home/git/gitorious"
nano /home/git/gitorious/doc/templates/centos/git-poller
RUBY_HOME="/opt/ruby"
GITORIOUS_HOME="/home/git/gitorious"
export _JAVA_OPTIONS=-Xmx64m
nano /home/git/gitorious/doc/templates/centos/stomp
RUBY_HOME="/opt/ruby"
GEMS_HOME="/opt/ruby"
GITORIOUS_HOME="/home/git/gitorious"
exit
gem install --no-ri --no-rdoc -v 1.5.0 json
gem install --no-ri --no-rdoc -v 1.3.1.1 rdiscount
gem install --no-ri --no-rdoc -v 0.8.7 rake
gem install --no-ri --no-rdoc -v 1.1.0 daemons
gem install --no-ri --no-rdoc -v 0.8.9 geoip
gem install --no-ri --no-rdoc -v 1.0 raspell
gem uninstall rake -v 0.9.2.2
cd /home/git/gitorious
bundle install
cp config/database.sample.yml config/database.yml
cp config/gitorious.sample.yml config/gitorious.yml
cp config/broker.yml.example config/broker.yml
su git
mkdir /home/git/data
mkdir /home/git/data/repositories
mkdir /home/git/data/tarballs
mkdir /home/git/data/tarball-work
chown -R git:git /home/git/data
#Включаем вход по ключам
mkdir /home/git/.ssh
chmod -R 700 /home/git/.ssh
touch /home/git/.ssh/authorized_keys
chmod 600 /home/git/.ssh/authorized_keys
chmod -R 700 /home/git/data
exit
chown -R git:git /home/git
chmod 711 /home/git
Create a secret cookie for the configuration file
apg -m 64
and copy the received data to a file
nano /home/git/gitorious/config/gitorious.yml
to cookie_secret line:
Example:
development:
cookie_secret: SwouncievNivJucivrevnisfookEcnasiarHamgogdipmopyicbyctyikBagArimgronugAmIsUkDifpoyftEggobviuzIpArgecHewElsOcubnuejEtDecerlyooHibsmivyecivfalakMarfAvikokip^ojyorwahonkIrEdeibZepbivsaftIdmapmic)frivetcetEceivepJuxNeipnidzaroyffAgVevfuIvDesemAfyacAppAtdeavayswenEjUcoofnafryefGewboshkyersufcawJontIavZenFeifWoitGejEajnoiWrysawidHewofOkheTwiOjFigWigbobinCushBurnErnodedLuenAtTeyznoynoryop
repository_base_path: "/home/git/data/repositories"
extra_html_head_data:
system_message:
gitorious_client_port: 80
gitorious_client_host: git.example.com
gitorious_host: git.example.com
gitorious_user: git
exception_notification_emails: [email protected]
mangle_email_addresses: true
public_mode: true
locale: en
archive_cache_dir: "/home/git/data/tarballs"
archive_work_dir: "/home/git/data/tarball-work"
only_site_admins_can_create_projects: true
hide_http_clone_urls: false
is_gitorious_dot_org: false
use_ssl: false
test:
cookie_secret: SwouncievNivJucivrevnisfookEcnasiarHamgogdipmopyicbyctyikBagArimgronugAmIsUkDifpoyftEggobviuzIpArgecHewElsOcubnuejEtDecerlyooHibsmivyecivfalakMarfAvikokip^ojyorwahonkIrEdeibZepbivsaftIdmapmic)frivetcetEceivepJuxNeipnidzaroyffAgVevfuIvDesemAfyacAppAtdeavayswenEjUcoofnafryefGewboshkyersufcawJontIavZenFeifWoitGejEajnoiWrysawidHewofOkheTwiOjFigWigbobinCushBurnErnodedLuenAtTeyznoynoryop
repository_base_path: "/home/git/data/repositories"
extra_html_head_data:
system_message:
gitorious_client_port: 80
gitorious_client_host: git.example.com
gitorious_host: git.example.com
gitorious_user: git
exception_notification_emails: [email protected]
mangle_email_addresses: true
public_mode: true
locale: en
archive_cache_dir: "/home/git/data/tarballs"
archive_work_dir: "/home/git/data/tarball-work"
only_site_admins_can_create_projects: true
hide_http_clone_urls: false
is_gitorious_dot_org: false
use_ssl: false
production:
cookie_secret: SwouncievNivJucivrevnisfookEcnasiarHamgogdipmopyicbyctyikBagArimgronugAmIsUkDifpoyftEggobviuzIpArgecHewElsOcubnuejEtDecerlyooHibsmivyecivfalakMarfAvikokip^ojyorwahonkIrEdeibZepbivsaftIdmapmic)frivetcetEceivepJuxNeipnidzaroyffAgVevfuIvDesemAfyacAppAtdeavayswenEjUcoofnafryefGewboshkyersufcawJontIavZenFeifWoitGejEajnoiWrysawidHewofOkheTwiOjFigWigbobinCushBurnErnodedLuenAtTeyznoynoryop
repository_base_path: "/home/git/data/repositories"
extra_html_head_data:
system_message:
gitorious_client_port: 80
gitorious_client_host: git.example.com
gitorious_host: git.matthouse.us
gitorious_user: git
exception_notification_emails: [email protected]
mangle_email_addresses: true
public_mode: true
locale: en
archive_cache_dir: "/home/git/data/tarballs"
archive_work_dir: "/home/git/data/tarball-work"
only_site_admins_can_create_projects: true
hide_http_clone_urls: false
is_gitorious_dot_org: false
use_ssl: false
We continue to configure:
nano /home/git/gitorious/config/broker.yml
production:
adapter: stomp
development:
adapter: stomp
test:
adapter: stomp
configure Mysql and initialize the database
mysql -uroot –p’'
create database gitorious;
create database gitorious_test;
create database gitorious_dev;
CREATE user 'git'@'localhost' IDENTIFIED BY '';
GRANT ALL ON gitorious.* TO 'git'@'localhost';
GRANT ALL ON gitorious_test.* TO 'git'@'localhost';
GRANT ALL ON gitorious_dev.* TO 'git'@'localhost';
FLUSH privileges;
exit;
nano /home/git/gitorious/config/database.yml
cd /home
chown -R git:git /home/git
cd /home/git
chmod -R 755 data
chmod 755 gitorious
cd /home/git/gitorious
nano Rakefile
#Добавить строку
require 'thread'
#перед
require 'tasks/rails'
cd /home
chown -R git:git /home/git
cd /home/git
chmod -R 755 data
chmod 755 gitorious
gem update --system 1.6.2
bundle exec rake gems:install
bundle exec rake db:create:all
bundle exec rake db:setup
bundle exec rake db:migrate
Ultrsphinx setup:
cd /home/git/gitorious
export RAILS_ENV=production
export PATH=/usr/local/sphinx/bin:$PATH
bundle exec rake ultrasphinx:configure RAILS_ENV=production
bundle exec rake ultrasphinx:index
bundle exec rake ultrasphinx:daemon:start RAILS_ENV=production
create links to init files and run the services necessary for Gitorious to work
ln -s /home/git/gitorious/doc/templates/centos/git-daemon /etc/init.d/git-daemon
chmod +x /etc/init.d/git-daemon
chkconfig --add git-daemon
service git-daemon start
ln -s /home/git/gitorious/doc/templates/centos/stomp /etc/init.d/stomp
chmod +x /etc/init.d/stomp
chkconfig --add stomp
service stomp start
ln -s /home/git/gitorious/doc/templates/centos/git-poller /etc/init.d/git-poller
cd /home
chown -R git:git /home/git
cd /home/git
chmod -R 755 data
chmod 755 gitorious
chmod +x /etc/init.d/git-poller
chkconfig --add git-poller
nano /home/git/gitorious/script/poller
# Добавить require 'thread' после строки $KCODE = 'u'
service git-poller start
ln -s /usr/local/bin/gitorious /usr/bin
cd /home
chown -R git:git /home/git
cd /home/git
chmod -R 755 data
chmod 755 gitorious
configure ultrasphinx
#создаем словарь
cd /home/git/gitorious
aspell config dict-dir
/usr/lib64/aspell-0.60
cp vendor/plugins/ultrasphinx/examples/ap.multi /usr/lib64/aspell-0.60/
bundle exec rake ultrasphinx:spelling:build
nano /home/git/gitorious/config/ultrasphinx/production.conf
#изменяем "address" на"listen"
listen = 0.0.0.0
#уменьшаем выделение памяти до 64Мб
indexer {
mem_limit = 64M
#делаем git-ultrasphinx демоном.
ln -s /home/git/gitorious/doc/templates/centos/git-ultrasphinx /etc/init.d/git-ultrasphinx
chmod +x /etc/init.d/git-ultrasphinx
memcached
Install memcached
yum install -y --enablerepo=remi memcached
service memcached start
chkconfig memcached on
Apache
yum install -y httpd httpd-devel mod_xsendfile curl-devel
#настройка xsendfile
nano /etc/httpd/conf.d/xsendfile.conf
#добавить после строки LoadModule
XSendFile on
XSendFilePath /home/git/data/tarballs
XSendFilePath /home/git/data/repositories
Install Ruby passenger
/opt/ruby/bin/passenger-install-apache2-module
Example httpd.conf
Example host.conf
Final commands:
chcon -R -h -t httpd_sys_script_exec_t /opt/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
service httpd configtest
service httpd start
disable the firewall (we have a clean system, it is not configured yet)
service iptables stop
Open git.example.com in your browser and enjoy the gitorious homepage
