轉-Gitorious搭建步驟

先標記一下,後續手動驗證

http://blog.csdn.net/king_sundi/article/details/7457475

安裝Gitorious

Git是一個分佈式的版本控制系統,用於Linux內核的管理。在推出後,Git也逐漸被用於其餘項目,一樣也取得了很大的成功。GitHub則是基於Git版本控制系統的,它提供基於互聯網的項目託管服務,但GitHub並不開源,因此我在網上找到了替代GitHub的開源項目託管系統:Gitorious。
安裝Gitorious並非一件輕鬆的事,因此就寫了這篇文章,一則能夠幫助那些準備安裝Gitorious的兄弟,二則也給本身作個備忘。
1、安裝第三方的相關依賴包:
Apache
sudo apt-get install -y build-essential apache2 apache2-threaded-dev libapache2-mod-xsendfile
MySQL
sudo apt-get install -y mysql-server mysql-client
注意:在安裝MySQL時,您將會被提示建立MySQL的root用戶密碼
PHPMyAdmin(可選)
sudo apt-get install -y phpmyadmin
設置時選擇apache二、並使用dbconfig-common來配置數據庫,並會被提示建立PHPMyAdmin管理員用戶密碼。
Git
sudo apt-get install -y git-core git-doc
其它依賴包
sudo apt-get install -y libexpat1-dev libxslt1-dev libcurl4-openssl-dev sendmail apg geoip-bin libgeoip1 libgeoip-dev imagemagick libmagick++-dev libpcre3 libpcre3-dev zlib1g zlib1g-dev zip unzip libyaml-dev libonig-dev memcached aspell libaspell-dev aspell-en
Ruby 和 RubyGems
sudo apt-get install -y ruby ruby-dev rubygems libruby libdbd-mysql-ruby libmysql-ruby
sudo REALLY_GEM_UPDATE_SYSTEM=1 gem update –system
sudo gem install –no-ri –no-rdoc rake
sudo gem install –no-ri –no-rdoc daemons
sudo gem install -b –no-ri –no-rdoc rmagick
sudo gem install -b –no-ri –no-rdoc stompserver
sudo gem install -b –no-ri –no-rdoc passenger
sudo gem install -b –no-ri –no-rdoc bundler
Sphinx(俄國人貢獻的開源搜索包)
sudo apt-get install -y sphinxsearch
2、下載Gitorious源代碼,在這裏將Gitorious放置在/var/www/gitoriou:
cd /var/www
sudo chown firehare:firehare /var/www
git clone git://gitorious.org/gitorious/mainline.git gitorious
cd gitorious
git submodule init
git submodule update
sudo ln -s /var/www/gitorious/script/gitorious /usr/bin
第2條語句是爲了方便處理,不用總是sudo,因此將/var/www目錄的全部者從root改成你的用戶名,在這裏我使用的是個人用戶名firehare。
3、配置初始化服務
在/var/www/gitorious/doc/templates/ubuntu目錄中有相應的服務腳本模板。將這些腳本模板拷至/etc/init.d目錄中:
cd /var/www/gitorious/doc/templates/ubuntu
sudo cp git-daemon git-ultrasphinx git-poller stomp /etc/init.d
sudo cp gitorious-logrotate /etc/logrotate.d/gitorious
sudo chmod 755 git-daemon git-ultrasphinx git-poller stomp
而後將服務配置成開機啓動
sudo update-rc.d stomp defaults
sudo update-rc.d git-daemon defaults
sudo update-rc.d git-ultrasphinx defaults
sudo update-rc.d git-poller defaults
最後因爲git-daemon git-ultrasphinx git-poller stomp腳本中的RUBY_HOME路徑指向」/opt/ruby-enterprise」,爲了方便起見,不一一修改啓動腳本,將建立一個連接:
sudo ln -s /usr/ /opt/ruby-enterprise
4、配置Apache
安裝Passenger
sudo /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11/bin/passenger-install-apache2-module
配置Passenger
sudo vi /etc/apache2/mods-available/passenger.load
而後在新建的passenger.load文件中輸入如下文字:
# Did you verify this matches the values from
# the ‘sudo /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11/bin/passenger-install-apache2-module’ command ?
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11
PassengerRuby /usr/bin/ruby1.8
啓用Apache模塊
sudo a2enmod passenger
sudo a2enmod rewrite
sudo a2enmod ssl
sudo /etc/init.d/apache2 restart
建立Gitorious站點文件
sudo vi /etc/apache2/sites-available/gitorious
而後在新建的Gitorious站點文件中輸入如下文字:

ServerName git.meranko.net
DocumentRoot /var/www/gitorious/publicphp

# Enable X-SendFile for gitorious repo archiving to work
XSendFile onmysql

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat 「%h %l %u %t \」%r\」 %>s %b \」%{Referer}i\」 \」%{User-Agent}i\」" combined
LogFormat 「%h %l %u %t \」%r\」 %>s %b」 common
LogFormat 「%{Referer}i -> %U」 referer
LogFormat 「%{User-agent}i」 agentgit

CustomLog /var/log/apache2/gitorious_access.log combined
TransferLog /var/log/apache2/gitorious_access.log
ErrorLog /var/log/apache2/gitorious_error.log

建立Gitorious SSL站點文件
sudo vi /etc/apache2/sites-available/gitorious-ssl
而後在新建的Gitorious站點文件中輸入如下文字:


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
DocumentRoot /var/www/gitorious/publicsql

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat 「%h %l %u %t \」%r\」 %>s %b \」%{Referer}i\」 \」%{User-Agent}i\」" combined
LogFormat 「%h %l %u %t \」%r\」 %>s %b」 common
LogFormat 「%{Referer}i -> %U」 referer
LogFormat 「%{User-agent}i」 agentshell

CustomLog /var/log/apache2/gitorious_ssl_access.log combined
TransferLog /var/log/apache2/gitorious_ssl_access.log
ErrorLog /var/log/apache2/gitorious_ssl_error.log數據庫



啓用Gitorious和Gitorious SSL網站
sudo a2dissite default
sudo a2dissite default-ssl
sudo a2ensite gitorious
sudo a2ensite gitorious-ssl
sudo /etc/init.d/apache2 restart
5、設置MySQL用戶
mysql -u root -p
Enter password: (輸入你在安裝包時肯定的Mysql根用戶密碼)
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘gitorious’@'localhost’ IDENTIFIED BY ‘<輸入密碼>‘ WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
6、配置Gitorious
首先確保全部gems版本的正確(安裝時會詢問你的sudo密碼)
cd /var/www/gitorious/
bundle install
bundle pack
再建立git系統用戶
sudo adduser –system –home /var/www/gitorious/ –no-create-home –group –shell /bin/bash git
sudo chown -R git:git /var/www/gitorious
而後建立一些Gitorious運行所需的東西
sudo su – git
mkdir .ssh
touch .ssh/authorized_keys
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
mkdir tmp/pids
mkdir repositories
mkdir tarballs
mkdir tmp/tarballs-work
chmod ug+rwx repositories
生成Gitorious的配置文件(注意:當前用戶爲git)
cp config/database.sample.yml config/database.yml
cp config/gitorious.sample.yml config/gitorious.yml
cp config/broker.yml.example config/broker.yml
在Gitorious的database.yml配置文件中的production段中確保正確的數據庫用戶名和名字(注意:當前用戶爲git)
在Gitorious的gitorious.yml配置文件中,要注意如下內容:
確保在production而非test中修改
repository_base_path應該是/var/www/gitorious/repositories
cookie_secret應該設爲多於30個字符的字符串,爲了方便起見,你可使用下列命令,而後將其輸出複製到這裏。
apg -m 64
gitorious_client_port應該設爲80
gitorious_host應該設置成客戶可使用的主機名(不然Cookie會出錯
archive_cache_dir應該設爲/var/www/gitorious/tarballs
archive_work_dir應該設爲/var/www/gitorious/tmp/tarballs-work
exception_notification_emails:你的郵箱
hide_http_clone_urls應該設爲true(它們須要額外的安裝工做)
is_gitorious_dot_org應該設false
public_mode應該設爲false
7、建立Gitorious數據庫
由於在RubyGems 1.6.0+ 而且 Rails < 2.3.11時存在BUG,原本能夠在config/boot.rb文件的頂部添加下列語句來解決,但因爲該文件註釋要求不要改變,因此就只好麻煩點,添加到Rakefile文件和config/environment.rb文件的require(File.join(File.dirname(__FILE__), ‘config’, ‘boot’))語句上方便可:
require ‘thread’
接下來的工做,咱們讓rake來作:
export RAILS_ENV=production
bundle exec rake db:create RAILS_ENV=production
bundle exec rake db:migrate RAILS_ENV=production
配置Sphinx搜索守護程序,將address設爲localhost
vi /var/www/gitorious/config/ultrasphinx/default.base
# Daemon options
searchd
{
# What interface the search daemon should listen on and where to store its logs
address = localhost
port = 3312
…….
而後繼續用rake來爲咱們配置:
bundle exec rake ultrasphinx:bootstrap RAILS_ENV=production
注意:本人在安裝在這一步時出現一個錯誤,提示以下,詳見第12行,因而本人查了一下數據庫,打開文件/var/www/gitorious/config/ultrasphinx/production.conf,找到base_tags.name語句,將其改爲tags,便可經過:
(in /var/www/gitorious)
Rebuilding configurations for production environment
Available models are Comment, Repository, MergeRequest, and Project
Generating SQL
$ indexer –config ‘/var/www/gitorious/config/ultrasphinx/production.conf’ –all
Sphinx 0.9.9-release (r2117)
Copyright (c) 2001-2009, Andrew Aksyonoffapache

using config file ‘/var/www/gitorious/config/ultrasphinx/production.conf’…
WARNING: key ‘address’ is deprecated in /var/www/gitorious/config/ultrasphinx/production.conf line 10; use ‘listen’ instead.
indexing index ‘main’…
ERROR: index ‘main’: sql_range_query: Unknown column ‘base_tags.name’ in ‘field list’ (DSN=mysql://gitorious:***@localhost:3306/gitorious_production).
total 0 docs, 0 bytes
total 0.005 sec, 0 bytes/sec, 0.00 docs/sec
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
Sphinx 0.9.9-release (r2117)
Copyright (c) 2001-2009, Andrew Aksyonoffbootstrap

using config file ‘/var/www/gitorious/config/ultrasphinx/production.conf’…
WARNING: key ‘address’ is deprecated in /var/www/gitorious/config/ultrasphinx/production.conf line 10; use ‘listen’ instead.
listening on 127.0.0.1:3312
WARNING: index ‘main’: preload: failed to open /var/www/gitorious/db/sphinx//sphinx_index_main.sph: No such file or directory; NOT SERVING
FATAL: no valid indexes to serve
Failed to start
Done
Please restart your application containers
建立Sphinx Cronjob
crontab -e * * * * * cd /var/www/gitorious && /usr/bin/bundle exec
建立管理員用戶
env RAILS_ENV=production ruby1.8 script/create_admin
8、重啓機器後你就能夠在Ubuntu 11.10上完成Gitorious的安裝了!OK!打完收功!!ubuntu

相關文章
相關標籤/搜索