0
2

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.

CentOS6.8+GitLab

Last updated at Posted at 2016-12-20

■ユーザー追加(開発環境)
 useradd dev
 useradd -g dev ユーザーネーム
 (例:useradd -g dev nishizawa)
 passwd ユーザーネーム
 passwd dev

 devのグループに入ってないとき
 gpasswd -a ユーザーネーム dev

■ユーザー追加(stading、release環境)
 useradd dev
 useradd git
 useradd -g dev ユーザーネーム
 passwd dev
 passwd git

■sudo権限追加
 
 visudo
  gitとに権限割り当て
  secure_pathに/usr/local/binを追加

■centosバージョンアップ
 sudo yum clean all
 sudo yum update glibc*
 sudo yum update yum* rpm* pyth*
 sudo yum clean all
 sudo yum update mkinitrd nash
 sudo yum update selinux*
 sudo yum update
 sudo /sbin/shutdown -r now

■selinux無効化
 sudo vi /etc/sysconfig/selinux
 SELINUX=disabled に書き換え

 sudo /sbin/shutdown -r now

■swap領域追加
 sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
 sudo mkswap /swapfile
 sudo swapon /swapfile
 sudo vim /etc/fstab
 /swapfile none swap defaults 0 0 ←行追加

■yumリポジトリ追加
 sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
 sudo rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

centos6.8からepelのミラーリポジトリが動作しないため、
/etc/yum.repos.d/epel.repoを書き換える(mirrorlist:OFF/baseurl:ON)

■パッケージインストール
 sudo yum install vim
 sudo yum install nkf
 sudo yum install colordiff
 sudo yum install man-pages-ja
 sudo yum install wget patch
 sudo yum install gcc gcc-c++

■git
 sudo yum install openssl-devel curl-devel expat-devel
 sudo yum install perl-ExtUtils-MakeMaker tcl*.x86_64 gettext

■GitLabインストール
 ※参考サイト:https://about.gitlab.com/downloads/

 1.
 sudo yum install curl openssh-server openssh-clients postfix cronie
 sudo service postfix start
 sudo chkconfig postfix on
 sudo lokkit -s http -s ssh

 2.
 curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
 sudo yum install gitlab-ce

 3.
 sudo gitlab-ctl reconfigure

 4.日本語化
 cd /usr/local/src
 sudo git clone https://github.com/ksoichiro/gitlab-i18n-patch.git
 cd /opt/gitlab/embedded/service/gitlab-rails
 sudo patch -p1 < /usr/local/src/gitlab-i18n-patch/patches/v8.14.2/app_ja.patch

 5.GitLabをブラウザで表示
  ⇒http://[サーバーアドレス]へアクセス
  ⇒GitLabの初期設定ページが表示
  ⇒初回はrootユーザーのパスワードを入力するページが表示

 ※表示されなかったら下記を確認
 アドレス確認
  ifconfig

 ネットワーク設定
  sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
  sudo service network restart

 ポート設定
  sudo vi /etc/sysconfig/iptables
  sudo /etc/init.d/iptables restart

■GitLabの再構成&実行
  sudo gitlab-ctl reconfigure

■GitLabの起動
 起動:sudo gitlab-ctl start
 再起動:sudo gitlab-ctl restart
 停止:sudo gitlab-ctl stop

■GitLabの設定ファイル
 パス:/etc/gitlab/gitlab.rb
 レポジトリパス設定 :git_data_dirs({"default" => "/var/opt/gitlab/git-data"})
 SSHホスト設定    :gitlab_rails['gitlab_ssh_host'] = 'サーバーIP'
 HTTPホスト設定   :external_url 'http://ホスト名'

■GitLabのレポジトリ
 デフォルトでは下記ディレクトリ配下にプロジェクトごとのレポジトリが作成される
 /var/opt/gitlab/git-data/repositories

■■■■■■■■■■■■■■■■■■■■■■
■■■ここからGitLabユーザーの操作■■■
■■■■■■■■■■■■■■■■■■■■■■

■GitLab新規アカウントの設定
 1.自分のローカルマシンへターミナルでログイン後、SSH Keyを作成
  ⇒mkdir .ssh
  ⇒chmod 700 .ssh
  ⇒cd .ssh
  ⇒ssh-keygen -t rsa
  ⇒/home/(ログインユーザー)/.ssh配下に下記のファイルが生成される
   id_rsa
   id_rsa.pub

 2.GitLabへブラウザからアクセスするとアカウント作成画面が表示されるので作成を行う

 3.GitLabへログインしSSH Keysの登録画面(http://(gitlabのドメイン)/profile/keys)
  ⇒1.で生成したid_rsa.pubの中身をKeyに設定(このKeyでユーザーとGitLabを結び付けていると思う)

 4.GitLabでプロジェクトを作成
  ・新規プロジェクトを作成した人がmaster
  ・masterがプロジェクトにメンバーを追加/権限付与(Guest/Reporter/Developer/Master)できる
  ・プロジェクト作成者のみがMasterへプッシュ可能
  ・メンバーはMaster以外のブランチならプッシュ可能

■新規プロジェクト作成後に行う基本的なgitコマンド
 (あとの操作は通常のgitコマンドと同じです)

 Git global setup
 git config --global user.name "ネーム"
 git config --global user.email "メールアドレス"
 (GitLabで作成したログイン情報と連動はしていないので任意に設定)

 新規にレポジトリを作成
  git clone git@(GitLabで設定したIPまたはホスト):(プロジェクトのレポジトリまでのパス)
 (例:git clone git@192.168.0.98:nishi/sample.git)
  cd temab
  touch README.md
  git add README.md
  git commit -m "add README"
  git push -u origin master

 既存のディレクトリやレポジトリがあるとき
  cd existing_folder
  git init
  git remote add origin git@(GitLabで設定したIPまたはホスト):(プロジェクトのレポジトリまでのパス)
  (例:git remote add origin git@192.168.0.98:nishi/sample.git)
  git add .
  git commit -m 'コメント'
  git push -u origin master

■開発環境にあるプロジェクトをGitLab上に登録
 ・GitLab上で新規プロジェクト作成
 ・作成したプロジェクトへメンバーの追加
 ・権限はdeveloper

 ・プロジェクト作成者
  mv sample(プロジェクトのフォルダ) test/sample(コピー先)
  cd test
  cd sample
  git remote -v(プッシュ先を確認)
  git remote set-url origin git@192.168.0.86:nishi/sample.git(GitLab上のリポジトリ先へ変更)
  git remote -v(プッシュ先を確認)
  git checkout -b master(GitLab上で最初に登録するブランチにする)
  git branch(現在のブランチを確認)
  git push -u origin master

  GitLab上にプロジェクトが反映されているか確認して終了

0
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?