Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I wanted to know how I can set up gitorious server on ubuntu and have it work locally. I'm running 12.04 and would like to get the latest version

share|improve this question
1  
    
i got: undefined method `source_index' for Gem:Module see here: pastebin.com/raw.php?i=YgV9Sym7 and here: pastebin.com/raw.php?i=3LYTygS0 BR, daniel –  ericbutters Mar 25 '13 at 11:38
add comment

2 Answers

up vote 8 down vote accepted

To install gitorious the latest one from git, follow these steps

First, lets go root by using

sudo su
[sudo] password for <username>:

Installing packages

When installing all these packages, you will be asked for a MySQL root password, which you should remember, because you will need it later on.

  aptitude install \
    build-essential zlib1g-dev tcl-dev libexpat-dev libxslt1-dev \
    libcurl4-openssl-dev postfix apache2 mysql-server mysql-client \
    apg geoip-bin libgeoip1 libgeoip-dev sqlite3 libsqlite3-dev \
    imagemagick libpcre3 libpcre3-dev zlib1g zlib1g-dev libyaml-dev \
    libmysqlclient15-dev apache2-dev libonig-dev ruby-dev rubygems \
    libopenssl-ruby libdbd-mysql-ruby libmysql-ruby \
    libmagick++-dev zip unzip memcached git-core git-svn git-doc \
    git-cvs irb

Installing the Ruby Gems

Gem.source_index is being deprecated. Using system 1.8.25 avoids the source_index error.

REALLY_GEM_UPDATE_SYSTEM=1 gem update --system 1.8.25

Now we can install all the necessary gems:

  gem install --no-ri --no-rdoc -v 0.8.7 rake && \
    gem install --no-ri --no-rdoc -v 1.1.0 daemons && \
    gem install -b --no-ri --no-rdoc \
        rmagick stompserver passenger bundler

Installing the Sphinx Search Server

wget http://sphinxsearch.com/files/sphinx-0.9.9.tar.gz && \
    tar -xzf sphinx-0.9.9.tar.gz && \
    cd sphinx-0.9.9 && \
    ./configure --prefix=/usr && \
    make all install

Getting Gitorious

  git clone git://gitorious.org/gitorious/mainline.git /var/www/gitorious && \
    cd /var/www/gitorious && \
    git submodule init && \
    git submodule update

Easy as pie. Now we just need to put the Gitorious binary on our path:

 ln -s /var/www/gitorious/script/gitorious /usr/bin

Configuring services

Gitorious needs a bunch of background services, so we need to copy the supplied startup scripts:

cd /var/www/gitorious/doc/templates/ubuntu/ && \
    cp git-daemon git-poller git-ultrasphinx stomp /etc/init.d/ && \
    cd /etc/init.d/ && \
    chmod 755 git-daemon git-poller git-ultrasphinx stomp

and enable them:

 update-rc.d git-daemon defaults && \
    update-rc.d git-poller defaults && \
    update-rc.d git-ultrasphinx defaults && \
    update-rc.d stomp defaults

We need to create an additional symlink, because all the startup scripts have RUBY_HOME set to /opt/ruby-enterprise (alternatively we could just patch the files, but this way it is easier and you can update the scripts if needed):

 ln -s /usr/ /opt/ruby-enterprise

Fixing git-ultrasphinx

As of March 2013 the git-ultrasphinx script is broken and will fail to start. Please edit /etc/init.d/git-ultrasphinx and check that the start, stop and restart commands are as follows (replace ultrasphinx:daemon with ts if necessary):

 START_CMD="cd $GITORIOUS_HOME && rake ts:start RAILS_ENV=production"
 STOP_CMD="cd $GITORIOUS_HOME && rake ts:stop RAILS_ENV=production"
 RESTART_CMD="cd $GITORIOUS_HOME && rake ts:restart RAILS_ENV=production"

Configuring Apache

Passenger

First of all, we need to compile the Apache2 passenger module:

$(gem contents passenger | grep passenger-install-apache2-module)

The passenger configuration script will tell you exactly what you’ll need to add to your apache configuration. The part you need to copy looks like this:

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
    PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.9
    PassengerRuby /usr/bin/ruby1.8

After you restart Apache, you are ready to deploy any number of Ruby on Rails applications on Apache, without any further Ruby on Rails-specific configuration! These three lines need to be inserted into

/etc/apache2/mods-available/passenger.load

Enabling necessary modules

   a2enmod passenger && \
        a2enmod rewrite && \
        a2enmod ssl

Creating the Apache2 sites

Type in :

nano /etc/apache2/sites-available/gitorious

And copy paste the following text

<VirtualHost *:80>
    ServerName your.server.com
    DocumentRoot /var/www/gitorious/public
</VirtualHost>

Type in

 nano /etc/apache2/sites-available/gitorious-ssl 

And copy paste the following text

<IfModule mod_ssl.c>
    <VirtualHost _default_:443>
        DocumentRoot /var/www/gitorious/public
        SSLEngine on
        SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
        SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
        BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
    </VirtualHost>
</IfModule>

Now we need to disable the default site, and enable our freshly created Gitorious sites:

  a2dissite default && \
    a2dissite default-ssl && \
    a2ensite gitorious && \
    a2ensite gitorious-ssl

Creating a MySQL user for gitorious

  mysql -u root -p

Enter the password you made while installing MySQL after the following prompt

Enter password:

Type this in line by line excluding the mysql> and changing <insert password> with your MySQL password you made while installing MySQL

 mysql> GRANT ALL PRIVILEGES ON *.* TO 'gitorious'@'localhost' IDENTIFIED BY '<insert password>' WITH GRANT OPTION;

mysql> FLUSH PRIVILEGES;

Configuring Gitorious

First of all, we need to make sure we have all gems in the correct version for Gitorious, so we run the following:

cd /var/www/gitorious/ && \
    bundle install && \
    bundle pack

Now we can create the user under which Gitorious will run and serve the Git repositories:

  adduser --system --home /var/www/gitorious/ --no-create-home --group --shell /bin/bash git && \
    chown -R git:git /var/www/gitorious

Then we need to create some stuff that Gitorious needs to run:

  su - git && \
    mkdir .ssh && \
    touch .ssh/authorized_keys && \
    chmod 700 .ssh && \
    chmod 600 .ssh/authorized_keys && \
    mkdir tmp/pids && \
    mkdir repositories && \
    mkdir tarballs

Creating the Gitorious configuration

Lets copy the sample configuration files to the correct path:

 cp config/database.sample.yml config/database.yml && \
    cp config/gitorious.sample.yml config/gitorious.yml && \
    cp config/broker.yml.example config/broker.yml

Now edit the config/database.yml and make sure you set the correct username and password in the production section. After that, we need to set a couple of things in config/gitorious.yml:

Make sure you are configuring the right section (not test:, but production:)

repository_base_path should be /var/www/gitorious/repositories
cookie_secret needs to be set to a random value >= 30 characters
gitorious_client_port should be 80
gitorious_host needs to be the exact hostname that clients will use (cookies get messed up otherwise)
archive_cache_dir should be /var/www/gitorious/tarballs
archive_work_dir should be something like /tmp/tarballs-work
hide_http_clone_urls should be true (they require extra unknown setup to work)
is_gitorious_dot_org should be false
Creating the Gitorious database

Because of an incompatibility of RubyGems with Rails < 2.3.11 you need to add the following line at the top of config/boot.rb:

require 'thread'

Now we let rake do all the work for us:

export RAILS_ENV=production && \
    bundle exec rake db:create && \
    bundle exec rake db:migrate && \
    bundle exec rake rake ts:conf && \
    bundle exec rake rake ts:rebuild

Create the Sphinx Cronjob

crontab -e 10 * * * * /var/www/gitorious/bin/rake ts:rebuild >/dev/null RAILS_ENV=production

Create an admin user

env RAILS_ENV=production ruby1.8 script/create_admin

Reboot

You’re finally done. Reboot your Ubuntu machine, and your Gitorious installation should be up and running.

Checking possible problems

Browse http://your.server.com/admin/diagnostics in order to check for possible problems.


Source: http://coding-journal.com/installing-gitorious-on-ubuntu-11-04/

share|improve this answer
    
These (above) instructions didn't work for me. http://edin.no-ip.com/comment/286 did, except for getting https. –  Jeff May 9 '12 at 23:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.