2014年9月23日
はじめに Gitのソースコードをインターネット上で共有したいけれど、セキュリティもろもろの関係からインターネット上に置くのがためらわれる場合など、GitHubライクなweb管理機能のあるGitlabを利用することができます。他にもGitHubをクローンしたようなものもありますが、これが一番メジャーそうだったので、今回はCentos7にGitlab 7.3.0をインストールする方法をご紹介します。 仮定 ご自身のドメインを myhost.jp と仮定し、GitLabをドメインのサブフォルダ myhost.jp/gitlab で運用するものとします。 git ,curl インストール [bash] $ sudo yum install curl git [/bash] git ユーザー追加 これがベストな方法か、少々疑問ですが、作業はすべて新規に作成するgit ユーザーで行ってください。 gitユーザーのパスワードはお任せします。 [bash] $ sudo useradd git -md /home/git -s /bin/bash $ sudo passwd git $ sudo nano /etc/suders [/bash] gitユーザーをsudo可能なユーザーに加えます。 [diff] # User privilege specification root ALL=(ALL:ALL) ALL + git ALL=(ALL:ALL) ALL [/diff] remi,epelリポジトリー追加 Redisなどのインストールに remiとepelのリポジトリー情報が必要なので、rpmダウンロード&インストール [bash] $ su – git $ wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm $ wget http://dl.fedoraproject.org/pub/epel/7/x86_64/epel-release-7-0.2.noarch.rpm $ sudo rpm -ivh remi-release-7.rpm epel-release-7-0.2.noarch.rpm [/bash] Mysql(mariadb)関連モジュールインストール [bash] $ sudo yum install mariadb-devel mariadb mariadb-libs mariadb-server [/bash] Mysql rootパスワード設定 [bash] $ mysqladmin -u root password ‘mynewpassword’ [/bash] Redis,関連モジュールインストール [bash] $ sudo yum install libunwind libunwind-devel gperftools-libs redis $ sudo yum install icu4c libicu-devel libxml2 libxml2-devel libxslt libxslt-devel cmake [/bash] mysql,redis起動、自動起動設定 [bash] $ sudo systemctl start mariadb $ sudo systemctl enable mariadb $ sudo systemctl start redis $ sudo systemctl enable redis [/bash] Rubyインストール [bash] $ sudo yum install ruby [/bash] mysql用のライブラリーのコンパイルに必要なものインストール [bash] $ sudo yum install gcc mysql-devel ruby-devel rubygems patch gcc-c++ [/bash] gemrc作成 これはRubyのお作法みたいなものなので気にせずにこの通りやってみてください。 [bash] $ nano ~/.gemrc [/bash] gem インストール時にドキュメントインストールなどを省略します。 [bash] install: –no-document update: –no-document [/bash] Railsインストール、ついでにMysql2のgemもインストール [bash] $ gem install rails mysql2 [/bash] gitlab-shellインストール [bash] $ git config –global user.name “GitLab” $ git config –global user.email “gitlab@localhost” $ git clone https://github.com/gitlabhq/gitlab-shell.git $ cd gitlab-shell/ $ git checkout -b 1.9.8 v1.9.8 $ cp config.yml.example config.yml $ nano config.yml [/bash] 以下のURL指定の部分を調整(gitlabをホストするURLを記述) [diff] – gitlab_url: “http://localhost/” ←コメントアウト + gitlab_url: “http://www.myhost.jp/gitlab/” [/diff] インストール実行 [bash] $ ./bin/install [/bash] gitlabインストール githubからソースをクローンします。(ダウンロードかなり時間食います。合計70mbぐらい) [bash] $ cd /home/git $ git clone https://github.com/gitlabhq/gitlabhq.git gitlab $ cd gitlab $ git checkout -b 7.3.0 v7.3.0 $ cp config/gitlab.yml.example config/gitlab.yml $ nano config/gitlab.yml [/bash] ホスト名設定(gitlabをホストするURLを記述)、相対ルートの設定 [diff] – host: localhost + host: www.myhost.jp https: false # Uncomment and customize the last line to run in a non-root path # WARNING: We recommend creating a FQDN to host GitLab in a…
Leave a comment