CentOS 6.2 ã« gitolite v3.03ãGitLab v2.6.2 ãã¤ã³ã¹ãã¼ã«ãã
前回 試ããæããçµæ§ãã¼ã¸ã§ã³ãä¸ãã£ããããªã®ã§ãgitolite 3.03 & GitLab 2.6.2 ãã¤ã³ã¹ãã¼ã«ãã¦ã¿ã¾ããã
2013.08.16 追è¨
æ°ãããã¼ã¸ã§ã³ã«ã¤ãã¦è¨äºãæ¸ãã¦ãã¾ãã
ãã¡ããåç
§ãã¦ãã ããã
GitLab 5.4.0 を CentOS 6.4 にインストールする
ç°å¢
使ç¨ããåã½ããã¦ã§ã¢ã®ãã¼ã¸ã§ã³ã¯ä»¥ä¸ã«ãªãã¾ãã
CentOS | 6.2(x86_64)ãMinimal |
---|---|
Git | 1.7.1 |
Ruby | ruby 1.9.3p194 |
gitolite | 3.03 |
GitLab | 2.6.2 |
äºåæºå
Ruby 1.9 ç³»ã®ã¤ã³ã¹ãã¼ã«ã«é¢ãã¦ã¯ããã§ã¯å®äºãã¦ãããã®ã¨ãã¦è§£èª¬ãçãã¾ãã
éçºããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãã¾ãã
# yum groupinstall -y "Development Tools"
ãã㧠git ãã¤ã³ã¹ãã¼ã«ããã¾ãã
ã¾ããCentOS 6.2 ã Minimal ã§ã¤ã³ã¹ãã¼ã«ãã㨠wget ãå ¥ã£ã¦ããªãã®ã§ããã®å ´åã¯ã¤ã³ã¹ãã¼ã«ãã¦ããã¾ãã
# yum install -y wget
ç§ã®ç°å¢ã§ã¯ SELinux ãæå¹ã«ãªã£ã¦ããå ´åã GitLab ããã®å
¬ééµã®è¿½å ã«å¤±æãã¦ãã¾ãã¾ããã
ãã®ãããããã§ã¯ SELinux ãç¡å¹ã«ãã¦ãã¾ãã
# setenforce 0
å®éã«éç¨ããå ´åã¯åèµ·åãã¦ãç¡å¹ã«ãªã£ãã¾ã¾ã«ãªãããã/etc/sysconfig/selinux ãç·¨éããå¿ è¦ãããã¾ãã
ããã¾ã§ã§äºåæºåã¯å®äºã§ãã
ã¦ã¼ã¶ã®ä½æã¨å ¬ééµã®æºå
gitolite 管çç¨ã¦ã¼ã¶ git 㨠gitlab å®è¡ç¨ã¦ã¼ã¶ gitlabhq ã¦ã¼ã¶ãä½æãã¾ãã
ã¾ããgitlabhq ã¦ã¼ã¶ã¯ git ã°ã«ã¼ãã«ãæå±ããã¦ããã¾ãã
# useradd git # useradd -G git gitlabhq
ã°ã«ã¼ãã«æå±ããã¦ã¼ã¶ãããªãã¸ããªãåç §ã§ããããã«ã/home/git ã«ã°ã«ã¼ãã«å¯¾ãããã¼ããã·ã§ã³ãè¨å®ãã¾ãã
# chmod g+rx /home/git
gitolite ã¸ç»é²ããããã®ç®¡çã¦ã¼ã¶ç¨å ¬ééµãä½æãããã gitlabhq ã¦ã¼ã¶ã«ãªããgitolite 管çç¨ã®å ¬ééµãä½æãã¾ãã
# su - gitlabhq $ ssh-keygen -t rsa -P "" -f ~/.ssh/gitadmin
ã¾ãã ssh-keyscan ã³ãã³ããå®è¡ããlocalhost ã ~/.ssh/known_hosts ã«è¿½å ãã¦ããã¾ãã
$ ssh-keyscan localhost >> ~/.ssh/known_hosts
root ã¦ã¼ã¶ã«æ»ããå ã»ã©ä½æããå ¬ééµã git ã¦ã¼ã¶ã®ãã¼ã ãã£ã¬ã¯ããªã«ç§»åããã¦ããã¾ãã
$ exit # root ã«æ»ãã¾ã # mv /home/gitlabhq/.ssh/gitadmin.pub /home/git
gitolite ã®ã¤ã³ã¹ãã¼ã«
git ã¦ã¼ã¶ã«ãªããgitolite ã github ãã ãã¦ã³ãã¼ããã¾ãã
# su - git $ wget --content-disposition https://github.com/sitaramc/gitolite/tarball/v3.03
ãã¦ã³ãã¼ããå®äºããããå±éã㦠$HOME/bin ã«ã¤ã³ã¹ãã¼ã«ãã¾ãã
$ tar xzf sitaramc-gitolite-v3.03-0-g75387fd.tar.gz $ mkdir $HOME/bin $ sitaramc-gitolite-b8bd7f5/install -ln
install -ln ã®å®è¡æãä¸è¨ã®ãããªã¨ã©ã¼ã¡ãã»ã¼ã¸ã表示ããã¾ããã
fatal: Not a git repository (or any of the parent directories): .git
ãã®ã¡ãã»ã¼ã¸ã¯ install ã¹ã¯ãªããå ã® 64 è¡ç®ä»è¿ã®ä»¥ä¸ã®è¡ã«ãã£ã¦åºåããã¦ããããã§ãã
my $version = `git describe --tags --long --dirty=-dt`;
ã©ããã install ã¹ã¯ãªããã git clone ãã¦ãã gitolite ãåæã¨ãã¦æ¸ããã¦ããããã§ãã
ã¡ãã»ã¼ã¸ã¯åºããã®ã®ã$HOME/bin 以ä¸ã¸ã®ã·ã³ããªãã¯ãªã³ã¯ã¯ã¡ããã¨ä½æãã¦ããã¦ãããããªã®ã§ãããã§ã¯ç¡è¦ãã¦é²ãããã¨ã«ãã¾ãã
è¨å®ãã¡ã¤ã« /home/git/.gitolite.rc ãä½æã㦠UMASK ãå¤æ´ãã¦ããã¾ãã
$ sh -c "PATH=$HOME/bin:$PATH; gitolite print-default-rc >> ~/.gitolite.rc" $ sed -i 's/0077/0007/g' ~/.gitolite.rc
å ã»ã©ä½æããå ¬ééµãå¼æ°ã« gitolite setup ãå®è¡ãã¾ãã
$ sh -c "PATH=$HOME/bin:$PATH; gitolite setup -pk /home/git/gitadmin.pub" Initialized empty Git repository in /home/git/repositories/gitolite-admin.git/ Initialized empty Git repository in /home/git/repositories/testing.git/ WARNING: /home/git/.ssh missing; creating a new one WARNING: /home/git/.ssh/authorized_keys missing; creating a new one
gitlabhq ã¦ã¼ã¶ã§ã® SSH è¨å®
gitlabhq ã¦ã¼ã¶ã«ãªãã~/.ssh/config ã以ä¸ã®ããã«ä½æãã¾ãã
$ exit # gitlabhq ã¦ã¼ã¶ã« su ãããã root ã«æ»ã # su - gitlabhq $ cat > ~/.ssh/config <<'_EOF_' Host localhost HostName localhost User git IdentityFile ~/.ssh/gitadmin _EOF_
ä½æããã権éãå¤æ´ãã¦ããã¾ãã
$ chmod 0600 ~/.ssh/config
ã¾ããgitlabhq ã¦ã¼ã¶ã§ã® git ã®åæè¨å®ãè¡ã£ã¦ããã¾ãã
ã¡ã¼ã«ã¢ãã¬ã¹ãªã©ã¯ç°å¢ã«åããé©å®å¤æ´ãã¦ãã ããã
$ git config --global user.email "[email protected]" $ git config --global user.name "gitadmin"
GitLab ã®ã¤ã³ã¹ãã¼ã«
root ã¦ã¼ã¶ã«ãªããEPEL ãªãã¸ããªã追å ãã¾ãã
$ exit # root ã«æ»ãã¾ã # rpm --import http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6 # rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-7.noarch.rpm
å¿ è¦ãªã©ã¤ãã©ãªãã¤ã³ã¹ãã¼ã«ãã¾ãã
# yum install -y python-devel python-pip redis libicu-devel mysql-devel sqlite-devel # pip-python install pygments # gem install bundler --no-rdoc --no-ri
ã¤ã³ã¹ãã¼ã«ãå®äºããã Redis ãèµ·åãã¦ããã¾ãã
# service redis start
gitlabhq ã¦ã¼ã¶ã«ãªããv2.6.2 ã® tarball ãåå¾ãå±éãã¾ãã
# su - gitlabhq $ wget --content-disposition https://github.com/gitlabhq/gitlabhq/tarball/v2.6.2 $ tar xzf gitlabhq-gitlabhq-v2.6.2-0-g39fecb5.tar.gz $ ln -s gitlabhq-gitlabhq-98c9231 gitlabhq
GitLab ãã»ããã¢ãããã¦ããã¾ãã
bundle install 㯠--deployment ãªãã·ã§ã³ä»ãã§å®è¡ãããã¨ã«æ³¨æãã¦ä¸ããã
$ cd $HOME/gitlabhq $ bundle install --deployment --without development test
è¨å®ãã¡ã¤ã«ã®éå½¢ãã³ãã¼ãã¾ãã
$ cp config/gitlab.yml.example config/gitlab.yml
ç°å¢ã«åããã¦ãµã¼ãè¨å®ãå¤æ´ãã¾ãã
$ vi config/gitlab.yml
ããã§ã¯ host ããµã¼ãã® IPã¢ãã¬ã¹ã«å¤æ´ãã¾ããã
# Gitlab application config file # Email used for notification # about new issues, comments email: from: [email protected] host: gitlabhq.com # Git Hosting congiguration git_host: system: gitolite admin_uri: git@localhost:gitolite-admin base_path: /home/git/repositories/ host: 192.0.2.0 git_user: git # port: 22 # Git settings # Use default values unless you understand it git: # Max size of git object like commit, in bytes # This value can be increased if you have a very large commits git_max_size: 5242880 # 5.megabytes # Git timeout to read commit, in seconds git_timeout: 10
次㫠DB è¨å®ãå¤æ´ãã¾ãã
ããã§ã¯ãã¹ããªã®ã§ sqlite ã使ãã¾ãã
$ cp config/database.yml.sqlite config/database.yml
ãã¡ã¤ã«å 容ã¯å¤æ´ããªãã¦ãåé¡ããã¾ããããããå¿ è¦ãããã°ç°å¢ã«åããã¦å¤æ´ãã¦ãã ããã
è¨å®ãã¡ã¤ã«ã®æºåãåºæ¥ããã以ä¸ãå®è¡ãã¦åæãã¼ã¿ãæå
¥ãã¾ãã
gitlab:app:setup ã¿ã¹ã¯ã失æããã®ãé²ããããtmp ãã£ã¬ã¯ããªãä½æãã¦ããå®è¡ãã¦ãã¾ãã
$ mkdir tmp $ bundle exec rake gitlab:app:setup RAILS_ENV=production
å®è¡å¾ã«ããã©ã«ãã®ç®¡çè ã¢ã«ã¦ã³ãæ å ±ã表示ãããã®ã§ã¡ã¢ãã¦ããã¾ãã
ããã¾ã§ã®è¨å®ã«åé¡ããªããã以ä¸ãå®è¡ãã¦ç¢ºèªãã¾ãã
$ bundle exec rake gitlab:app:status RAILS_ENV=production
ãã® rake ã¿ã¹ã¯ã§ GitLab ãç°å¢è¨å®ã®ãã§ãã¯ãè¡ã£ã¦ãããã®ã§ãããä½æ ã UMASK ã®é¨åã®ã¿ãå®éã«ã¯å¤æ´ãã¦ããã«ãé¢ããã常㫠NG ã¨ãªã£ã¦ãã¾ãã¾ããã
UMASK for .gitolite.rc is 0007? ............NO
ã©ãã GitLab ã®ãlib/tasks/gitlab/status.rakeãå
ã® 52è¡ç®ä»è¿ã.gitolite.rc å
ã® UMASK æå®è¡ã grep ãã¦ããç®æã®æ£è¦è¡¨ç¾ãå¤ããã¨ãåå ã®ããã§ãã~
以ä¸ã®ããã«ãlib/tasks/gitlab/status.rakeããä¿®æ£ããã¨ã¡ããã¨å¤æ´ããã§ãã¯ãã¦ãããããã«ãªãã¾ãã
unless open("#{GIT_HOST['base_path']}/../.gitolite.rc").grep(/UMASK\s*=>\s*0007/).empty?
ç°å¢ãã§ãã¯ã¾ã§åé¡ãªãå®äºãããããµã¼ããèµ·åãã¾ãã
$ bundle exec rails s -e production
ãµã¼ããèµ·åããããã©ã¦ã¶ããã¢ã¯ã»ã¹ãããªãã¸ããªã®ä½æã cloneãpush ãªã©ã試ãã¦ã¿ã¦ä¸ããã
åé¡ãªãåä½ãã¦ããã° GitLab ã®æ§ç¯ã¯å®äºã§ãã
â» å
ã»ã©ãæ¸ãã¾ãããããããã©ã¦ã¶ä¸ããå
¬ééµãç»é²ãã¦ã追å ãããªãæ¹ã¯ããµã¼ãã® SELinux ãç¡å¹ã«ãã¦ã¿ã¦ãã ããã
ç§ã®ç°å¢ã§ã¯ SELinux ãæå¹ã ã¨éµã追å ãããã確èªã®ãã gitolite sshkeys-lint ãã¦ã¿ã㨠Permission denied ã«ãªã£ã¦ãããã¨ããç¾è±¡ãçºçãã¾ããã