当前位置: 首页 > 工具软件 > Gitorious > 使用案例 >

Gitorious 安装笔记

邹山
2023-12-01

                                                在Centos上安装Gitorious

    软件要求:

       

  •  Web server (Apache)
  • Database server (MySQL)
  • Ruby (Enterprise Edition

 先安装依赖软件包:

(Gitorious 需要很多软件:

     yum update

      yum install -y git git-svn pcre pcre-devel zlib zlib-devel sendmail ;

     yum -y groupinstall "DevelopmentLibraries" "Development Tools" ;

    yum install -y libssh2 libssh2-devel openssh openssh-server \ 

   memcached libyaml libyaml-devel ImageMagick ImageMagick-devel  \ 

   apr-devel uuid java-1.6.0-openjdk readline-devel glibc-devel \ 

   openssl-devel gcc-c++ gcc-c++ zlib-devel openssl-devel readline-devel\ 

    sphinx

安装Ruby和Rubygems

Gitorious要求ruby的版本>=1.86

我们用Ruby企业版本1.8.7 ,其已包含rubygems。

Wget http://rubyforge.org/frs/download.php/68719/ruby-enterprise-1.8.7-2010.01.tar.gz

tar xzvfruby-enterprise-1.8.7-2010.01.tar.gz 

./ruby-enterprise-1.8.7-2010.01/installer

 

安装需求的Gems

先升级rubygems

gem update –system

(如果出现不能升级请添加gem源:gem source –a http://rubygems.org/。如果不用可以-d删除)

然后安装需要的gem包

gem install --no-ri --no-rdoc rails mongrelmime-types \ 

   textpow chronic ruby-hmac daemons mime-types oniguruma passenger \ 

   textpow chronic BlueCloth ruby-yadis ruby-openid geoip ultrasphinx \ 

rspec rspec-rails RedCloth echoe hoe diff-lcsstompserver json mysql

注意:最新版本的rack和我们测试的环境部兼容,请用1.0.1版本替换。

gem install --no-ri --no-rdoc -v 1.0.1 rack

安装并配置Mysql数据库

  安装mysql:

·        yuminstall mysql mysql-server mysql-libs mysql-devel

开启服务:

 

·        servicemysqld start

  给root用户设置密码(这里的root是mysql的root,不是linux的root)

 

·        mysqladmin-u root password  '123'(我设的是123)

 

添加用户git作为Gitorious的使用者

adduser --create-home git(添加用户)

克隆Gitorious的源代码

   进入你想下载这个应用的地方,我的是/var/www/。

   cd /var/www

git clonegit://gitorious.org/gitorious/mainline.git gitorious

  这样整个Gitorious application 就会被克隆到/var/www/gitorious中

建立一个软连接

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

Repositoriesand Tarballs建立目录

mkdir /var/git

mkdir /var/git/repositories 

mkdir /var/git/tarballs 

mkdir /var/git/tarball-work

改变application目录的拥有者

chown -R git:git /var/git /var/www/gitorious

安装web服务器
   yum install -y httpd httpd-devel

(这里用的是apache)

安装和配置passenger

/opt/ruby-enterprise/bin/passenger-install-apache2-module

(如果找不到请find / -name passenger-install-apache2-module)

在/etc/httpd/conf.d/ touch ruby.conf

在ruby.conf里添加如下内容

LoadModule passenger_module/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so

PassengerRoot/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.11 

PassengerRuby /opt/ruby-enterprise/bin/ruby

(注意!这里的路径在执行/opt/ruby-enterprise/bin/passenger-install-apache2-module的时候会给出。)

并且apache设置如下:

(apache配置文件在/etc/httpd/conf/httpd.conf里)

ServerName 10.210.213.9

 DocumentRoot /var/www/gitorious/public

 <Directory /var/www/gitorious/public> 

    AllowOverride all 

    Options -MultiViews 

 </Directory> 

Set Up Gitorious

切换用户:sugit

vi  ~/.bashrc

然后把以下内容添加到里面去

export RUBY_HOME=/opt/ruby-enterprise

exportGEM_HOME=$RUBY_HOME/lib/ruby/gems/1.8/gems 

export PATH=$RUBY_HOME/bin:$PATH

接下来执行source ~/.bashrc

制作authorized_keys文件

su git(重要)

mkdir ~/.ssh

chmod 700 ~/.ssh  (重要,不然ssh安全设置原因而无法登陆)

touch ~/.ssh/authorized_keys 

chmod 600 ~/.ssh/authorized_keys

配置

mkdir -p tmp/pids

 

chmod ug+x script/*

 

然后cd /var/www/gitorious

 

cp config/database.sample.ymlconfig/database.yml

cp config/gitorious.sample.ymlconfig/gitorious.yml 

cp config/broker.yml.example config/broker.yml

这里配置很重要

(gitorious.yml的配置要注意几点,第一把里面的development和test都注释掉,不然会出现you config/gitorious.yml havenot entry for current rails environment.

第二 gitorious_client_port: 80 不是3000第三一定要把use_ssl: 改为false,不然会出现500错误。第四用apg –m 64 产生的码替换cookie_secret的默认值,不要有空格和新行。以下是我的全部配置 做一下参考

production:

  # The sessionsecret key (`apg -m 64` is always useful for this kinda stuff)

  cookie_secret:threshinevtejletJoavyimElIkJuvgaygAgIvWyctAirHeabhefwyajKubmiammryttOfjoisweitFakudNeavwomCockadnojRytAupIfHagyifegwiLozNiFludKiavhaicmokujEndipVusHivnuexIcovworckyoibUtVikpaidbunkoobVirdepBooheukcemOrbubBitleb*QuebVaTewkUchCafapsheuctesErvEdQuodNuicGogdeuBibejOufyikaf3OldIbrEwfyinkubGeygArbEmRaiswobbykleftUdAstEbtyin9UrvanyokyoghwypatUnkyavHedthepDobjisupetEeHulkeacsyidnupcicyanun

 # The path wheregit repositories are stored. The actual (bare) repositories resides

  # inrepository_base_path/#{project.slug}/#{repository.name}.git/:

 repository_base_path: "/var/git/repositories"

 

  # Stuff that's inthe html <head>. custom stats javascript code etc

 extra_html_head_data:

 

  # System messagethat will appear on all pages if present

  system_message:

 

  # Port the./script/gitorious script should use:

 gitorious_client_port: 80

 

  # Host the./script/gitorious script should use:

 gitorious_client_host: 10.210.213.9

 

  # Host which isserving the gitorious app, eg "gitorious.org"

  gitorious_host:10.210.213.9

 

  # User which isrunning git daemon

  gitorious_user:git

 

  # Email addressto the support for the Gitorious server

 gitorious_support_email: support@gitorious.org

 

  # Email spam onserver errors to:

 exception_notification_emails: 

 

  # Mangle visiblee-mail addresses (spam protection)

 mangle_email_addresses: true

 

  # Enable orDisable Public Mode (true) or Private Mode (false)

  public_mode: true

 

  # Define yourlocale

  locale: en

 

  # Where should westore generated tarballs?

  # (should bereadable by webserver, since we tell it to send the file using X-Sendfile)

 archive_cache_dir: "/var/git/tarballs"

  # Which directoryshould we work in when we generate tarballs, before moving

  # them to theabove dir?

  archive_work_dir:"/var/git/tarballs-work"

 

  # is it only siteadmins who can create new projects?

 only_site_admins_can_create_projects: false

 

  # Should we hideHTTP clone urls?

 hide_http_clone_urls: false

 

  # Use SSL?Requires web server configuration. Recommended for security. Forces the use of

  # HTTPS on loginpage and all pages while user is logged in

  use_ssl: false

 

  # Is this gitorious.org? Read: should we havea very flashy homepage?

 is_gitorious_dot_org: false

 

  # Pick a defaultlicense

  #default_license:GNU Affero General Public License (AGPLv3)

 

  # Terms ofservice and privacy policy

  terms_of_use:false

  terms_of_service_url:http://en.gitorious.org/tos

 privacy_policy_url: http://en.gitorious.org/privacy_policy

 

  # Messaging queueconfiguration

  # Gitorious shipswith two message queue implementations; Stomp via the

  # ActiveMessaginggem and Resque. A TorqueBox implementation is on its way.

  # Possiblevalues: stomp, resque, test, sync. Default value is stomp. The

  # testimplementation is intended for unit testing only, not for production or

  # development use(messages are only stored in a list, never processed).

  # The syncadapter is intended for development use, but may also suit low

  # traffic setupswhere performance is not critical.

 messaging_adapter: stomp

然后database.yml 只要修改里面的passwd就行  改为我们设的123,记得密码和passwd 中间有一个空格。

执行bundle install

(如果出现you have actived rake(0.9.2) ,but rake is locked at 0.8.7等 请修改Gemfile.lock,把里面的版本号改了就行)

在git用户下执行

rake db:create RAILS_ENV=production

rake db:migrate RAILS_ENV=production

rake ultrasphinx:configure RAILS_ENV=production(搜索功能)

rake ultrasphinx:indexRAILS_ENV=production  (建立索引)

rake ultrasphinx:daemon:start RAILS_ENV=production

(rake命令最容易出错,如果出现未定义常量,请Rakefile最上面添加require ‘tread’如果还不行就在config/environment.rb也加上这一条。注意rake命令和bundle命令都要在/var/www/gitorious下执行,rake,ruby,bundle执行的时候如果出现找不到命令的时候查看环境变量的设置是否正确,或者用绝对路径执行。)

然后添加任务 crontab –e

* * * * * cd /var/www/gitorious &&/opt/ruby-enterprise/bin/rake ultrasphinx:index RAILS_ENV=production(实时更新索引)

脚本

把git-daemon和git-ultrasphinx从doc/templates/centos拷贝到/etc/init.d里

脚本gitorious-poller和stomp必须自己写

 

gitorious-poller

 

#!/bin/sh

# poller      Startup script for Gitorious's poller 

# chkconfig: - 86 15 

# description: Gitorious's poller script is simple workerthat polls \ 

#             tasks from stomp server queue and executes them. 

# processname: poller

 

/bin/su - git -c "cd /var/www/gitorious;RAILS_ENV=production ./script/poller $@"

Stomp

#!/bin/sh

# stomp       Startup script for stomp server  

# chkconfig: - 85 15 

# description: Stomp server is simple task queue serverthat \ 

#              usesstomp protocol.      

# processname: stomp 

# config: /etc/stompserver.conf

 

/bin/su - git -c "cd /var/www/gitorious;RAILS_ENV=production; stompserver -C /etc/stompserver.conf $@"

把这四个文件都放到/etc/init.d/里

然后修改权限

sudo chmod 755 git-daemon git-ultrasphinxgitorious-poller stomp

最后开启服务

chkconfig --add stomp

chkconfig --add git-daemon 

chkconfig --add gitorious-poller 

chkconfig --add git-ultrasphinx 

chkconfig --add memcached

 

chkconfig stomp on 

chkconfig git-daemon on 

chkconfig gitorious-poller on 

chkconfig git-ultrasphinx on 

chkconfig memcached on

service git-ultrasphinx start

service stomp start 

service memcached start 

service gitorious-poller start 

service git-daemon start  

service httpd restart

 

如果出现无法创建repository  ,请把/var/git/的拥有者改为git

并且修改这个目录权限为777

所有的服务最好也以git用户执行。

chown –R git:git /var/git  

另外gitorious的日志在/var/www/gitorious/log里,多看看这里有助于分析问题。

以上所有给出的目录可能和你实际的目录会有不同,请注意更改。

安装过程中出现的问题会比这多得多,多google就是了。

粗略笔记,仅供参考。

 类似资料: