0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS7でGitLab CE構築

Last updated at Posted at 2020-01-30

CentOS7でGitLabサーバー構築

前回SVNリポジトリを、GitLabのリポジトリに移行する手順について紹介しました。

しかし移行先はGitLab上のサーバーだったため、今回はGitLabの特徴でもあるセルフホスト(自前のサーバー)で、SVNリポジトリをGitLabのリポジトリに移行する手順について紹介したいと思います。

前提条件

・すでにSVNのローカルレポジトリ作成済み
・yum update済みのCentOS7サーバー

GitLab CE

GitLab CE(GitLab Community Edition)はセルフホスト用にインストールできるOSSです。

他にも、GitLab EE(GitLab Enterprise Edition) という、有料版があります。

ただ、GitLab EEはサポートや大規模開発などにならないと必要になるオプションがないので、今回はGitLab CEを使用していきたいと思います。

GitLab CEの構築

ここから、GitLab CEを構築する手順について紹介していきたいと思います。

GitLab CE構築に必要なパッケージ確認

まず、GitLab CE構築に必要なsshとpostfix(メール転送ソフトウェア)が起動しているか確認します。(CentOS7ではデフォルトで起動していました)

# systemctl status sshd
# systemctl status postfix

GitLab CEインストール

GitLab CEのリポジトリーを追加し、インストールします。

# cd /usr/local/src
# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

# EXTERNAL_URL="IPアドレス" yum install -y gitlab-ce

EXTERNAL_URLにCentOS7のIPアドレスを記載することで、そのIPアドレスでGitLabにアクセスできます。

その後、設定を反映するために以下のコマンド記載し、指定したIPアドレスにGitLabのパスワード設定ページが出ればGitLab CEの構築完了です。

# gitlab-ctl reconfigure

パスワードは再設定が必要なので、rootでログインするパスワードをサイド入力してSign inしてください。

SVNリポジトリをGitLabリポジトリに移行

すでにSVNリポジトリをGitLabリポジトリに移行は、前回の記事で紹介しています。

しかし今回はMacではなく、CentOS7のローカルサーバーから構築して、少しエラーなどを吐いたので、その解決方法に関して記載していきます。

CentOS7にGitインストール

CentOS7にインストールされているデフォルトのGitでは、git svnコマンドなどが使えないので、最新版のGitをインストールします。

すでにあるGitをremove
# yum remove git 

Gitのライブラリインストール
# yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker autoconf

wgetコマンド使用のためのパッケージインストール
# yum install -y wget

最新版のGitインストール
# wget https://www.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz
# tar vfx git-2.9.5.tar.gz
# cd git-2.9.5
# make configure
# ./configure --prefix=/usr
# make all
# make install

バージョン確認
# git --version
git version 2.9.5

前回同様ローカルのSVNリポジトリからGitLabリポジトリにプッシュ

GitLabで空のリポジトリを作成後、ローカルのCentOS7サーバーでSVNリポジトリをクローンします。

しかし前回同様に進めていったら、git svn initでCan't locate SVN/Core.pm in @INCというエラーがでました。

また、git svn fetchでは、can't locate digest/md5.pm in @INCというエラーが。

これを解消するために、前もってyumでパッケージをインストールしておきます。

# yum install -y subversion perl
# yum install -y perl-Digest-MD5

その後、前回同様、SVNリポジトリ作成。

# mkdir svn_repo
# cd svn_repo
# git svn init --prefix=svn/ http://SVNリポジトリ名
# git svn fetch

SVNリポジトリを作成したらこれも前回同様、空のGitLabリポジトリにプッシュする。

$ git remote add origin GitLabクローンURL
$ git push -u origin master

GitLabにアクセスしリポジトリとコミット履歴が引き継がれていることを確認できたら、GitLab CEの構築、CentOS7でのSVNリポジトリをGitLabリポジトリに移行は完了です。

参考文献

https://qiita.com/homines22/items/7572cdba2d60a00a3ffc
https://qiita.com/You_name_is_YU/items/34a09ab130e89fbfc459
https://github.com/termux/termux-packages/issues/2516
https://qiita.com/msakamoto_sf/items/78c322cb8656615ce134

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?