gitlab5.4をCentOS6.4にインストールする

提供: Wikiducca
2019年1月1日 (火) 13:40時点におけるゆっくりヌオック (ノート | 投稿記録)による版

移動: 案内検索

Wikiduccaは終了しました。今後はゴールドペディアをご利用ください。<nowiki>Wikiduccaは終了しました。今後はゴールドペディアをご利用ください。<nowiki>Wikiduccaは終了しました。今後はゴールドペディアをご利用ください。<nowiki>Wikiduccaは終了しました。今後はゴールドペディアをご利用ください。<nowiki>Wikiduccaは終了しました。今後はゴールドペディアをご利用ください。<nowiki>Wikiduccaは終了しました。今後はゴールドペディアをご利用ください。<nowiki>Wikiduccaは終了しました。今後はゴールドペディアをご利用ください。= 概要 = gitlab5.4 を CentOS6.4(sakura VPS) にインストールする。 = 作業環境 = == OS など == OS: CentOS6.4 ドメイン名: example.jp httpd: httpd-2.2.15-28.el6.centos.x86_64 暗号化: https を使う ssh port: 10022 == インストールするもの == ruby: 1.9.3 git: 1.8.3.4 gitlab: 5.4 gitlab-shell: 1.7.0 = 作業内容 = == ruby と git のアンインストール == 既に rpm 版が入っている場合。 入っていなければ飛ばしてよい。 # yum remove ruby # yum remove git == rvm で ruby をインストール == # bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer ) # source /etc/profile.d/rvm.sh # rvm install 1.9.3 == gem で必要なものをインストール == # gem install bundler --no-rdoc --no-ri # gem install charlock_holmes --version '0.6.9' --no-rdoc --no-ri == DB(mysql) 設定 == * ユーザ名: gitlabhq * ホスト: localhost * パスワード: XXXXXXXXXX * DB名: gitlabhq_production <pre> # mysql -u root -p mysql> CREATE DATABASE gitlabhq_production; Query OK, 1 row affected (0.03 sec) mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlabhq'@'localhost' identified by 'XXXXXXXXXX'; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye </pre> == redis のインストールおよび起動 == もし見つからなければ必要なリポジトリを追加する。 # yum install redis # chkconfig redis on # service redis start == 最新版 git のインストール == <pre> # cd /usr/local/src # wget https://git-core.googlecode.com/files/git-1.8.3.4.tar.gz # tar zxvf git-1.8.3.4.tar.gz # cd git-1.8.3.4 # ./configure --prefix=/usr/local # make # make install # /sbin/ldconfig </pre> == git ユーザの追加 == # adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git git # su - git <pre> $ mkdir .ssh $ touch .ssh/authorized_keys $ chmod 700 .ssh $ chmod 600 .ssh/authorized_keys $ git config --global user.name "GitLab" $ git config --global user.email "[email protected]" </pre> == gitlab-shell のインストール == <pre> $ git clone https://github.com/gitlabhq/gitlab-shell.git $ cd gitlab-shell $ git checkout -b v1.7.0 v1.7.0 $ cp config.yml.example config.yml $ vi config.yml $ diff config.yml config.yml.example 5c5 < gitlab_url: "https://example.jp/" --- > gitlab_url: "http://localhost/" $ ./bin/install </pre> == gitlab のインストール == <pre> $ cd ~ $ git clone https://github.com/gitlabhq/gitlabhq.git gitlab $ cd gitlab $ git checkout 5-4-stable $ cp config/gitlab.yml.example config/gitlab.yml $ vi config/gitlab.yml $ diff -u config/gitlab.yml.example config/gitlab.yml 18,20c18,20 < host: localhost < port: 80 < https: false --- > host: example.jp > port: 443 > https: true 31c31 < email_from: gitlab@localhost --- > email_from: [email protected] 34c34 < support_email: support@localhost --- > support_email: [email protected] 155a156 > ssh_port: 10022 161c162,163 < bin_path: /usr/bin/git --- > #bin_path: /usr/bin/git > bin_path: /usr/local/bin/git $ chown -R git log/ $ chown -R git tmp/ $ chmod -R u+rwX log/ $ chmod -R u+rwX tmp/ $ mkdir /home/git/gitlab-satellites $ mkdir tmp/pids/ $ chmod -R u+rwX tmp/pids/ $ cp config/puma.rb.example config/puma.rb $ mkdir tmp/sockets $ cp config/database.yml.mysql config/database.yml $ vi config/database.yml $ diff config/database.yml.mysql config/database.yml 10,11c10,11 < username: root < password: "secure password" --- > username: gitlabhq > password: "XXXXXXXXXX" $ bundle install --deployment --without development test postgres $ bundle exec rake gitlab:setup RAILS_ENV=production ~ ry ~ [email protected] password......5iveL!fe $ exit </pre> === 起動スクリプトの準備 === # curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab-centos # chmod +x /etc/init.d/gitlab # chkconfig --add gitlab そのまま起動しようとしたところ、 <pre> Starting puma: bash: /usr/bin/bundle: /usr/bin/ruby: bad interpreter: そのようなファイルやディレクトリはありません [失敗] Starting sidekiq: bash: /usr/bin/bundle: /usr/bin/ruby: bad interpreter: そのようなファイルやディレクトリはありません [失敗] </pre> というエラーになってしまったため以下のように書き換えた。 // かなり泥臭い。ほかに良い方法があれば教えてください。 <pre> # diff /tmp/gitlab-centos /etc/init.d/gitlab 36c36 < RUBY_PATH_PATCH="PATH=$PATH:/usr/local/bin:/usr/local/lib:/home/git/bin && export PATH && " --- > RUBY_PATH_PATCH="PATH=$PATH:/usr/local/rvm/gems/ruby-1.9.3-p448/bin:/usr/local/rvm/bin:/usr/local/bin:/usr/local/lib:/home/git/bin && export PATH && " 43c43 < daemon --pidfile=$UPID --user=$USER "$RUBY_PATH_PATCH bundle exec puma $OPTS" --- > daemon --pidfile=$UPID --user=$USER "$RUBY_PATH_PATCH /usr/local/rvm/gems/ruby-1.9.3-p448/bin/bundle exec puma $OPTS" 50c50 < daemon --pidfile=$SPID --user=$USER "$RUBY_PATH_PATCH RAILS_ENV=production bundle exec rake sidekiq:start" --- > daemon --pidfile=$SPID --user=$USER "$RUBY_PATH_PATCH RAILS_ENV=production /usr/local/rvm/gems/ruby-1.9.3-p448/bin/bundle exec rake sidekiq:start" </pre> === 起動 === <pre> # /etc/init.d/gitlab start Starting puma: Puma starting in single mode... * Version 2.3.1, codename: Delicious Thin Mints * Min threads: 0, max threads: 16 * Environment: production * Listening on unix:///home/git/gitlab/tmp/sockets/gitlab.socket * Daemonizing... [ OK ] Starting sidekiq: [ OK ] </pre> === 初期化 === # su - git <pre> $ cd gitlab $ bundle exec rake gitlab:env:info RAILS_ENV=production $ bundle exec rake gitlab:check RAILS_ENV=production $ exit </pre> == passengerのインストール == # gem install passenger --no-rdoc --no-ri # export APXS2=/usr/sbin/apxs # export PATH=/usr/sbin:$PATH # passenger-install-apache2-module === httpd 設定 === # cd /etc/httpd/conf.d # vi passenger.conf 内容: LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.10/buildout/apache2/mod_passenger.so PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.10 PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-1.9.3-p448/ruby ==== バーチャルホスト追加 ==== 鍵ファイルのパスとかは適当に編集してください。 # vi ssl.conf 内容: <pre> <VirtualHost *:443> DocumentRoot "/home/git/gitlab/public" ServerName example.jp SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW SSLCertificateFile /home/sites/example.jp/ssl/server.crt SSLCertificateKeyFile /home/sites/example.jp/ssl/server.key SSLCertificateChainFile /home/sites/example.jp/ssl/sub.class1.server.ca.pem <Files ~ "\.(cgi|shtml|phtml|php3?)$"> SSLOptions +StdEnvVars </Files> SetEnvIf User-Agent ".*MSIE.*" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog logs/ssl_request_log \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" <Directory /> AllowOverride None </Directory> <Directory "/home/git/gitlab/public"> Options Includes FollowSymLinks -MultiViews AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> </pre> 以上で httpd を再起動する。 == 動作確認 == https://example.jp にアクセスしてみる。 もし、エラーになった場合は、 /home/git/ のパーミッションかもしれない。 700 から 755 にしたところアクセスできた。 初回のアクセスは結構時間がかかる。 アクセスできたら以下の情報でログインし PW を変更する。 ID: [email protected] PW: 5iveL!fe 以上。 [[Category:GitLab]] [[Category:フリーソフト・オープンソース]]