はじめに
前回記事のCentOS7バージョンGitlabを公式ドキュメントに従いインストールする方法をメモをメモしておきます。
CentOS7になり、serviceコマンド、chkconfigコマンドが使えなく(互換なし)なってしまい、新たにsystemctlコマンドがでたりなどの違いや、DBもmysqlからmariaDBへ変更されたりとCentOS7のバージョンアップはいままでと結構違っています。
改めてGitLabをCentOS7へインストールしていきます。
インストール手順概要
公式サイト
https://about.gitlab.com/
公式サイトのトップページより「Downloads」ボタンをクリックし、「I want to install GitLab on」でOSを選択します。
対象のOSを選択します ※今回はCentOS7
1. Install and configure the necessary dependencies
sudo yum install openssh-server sudo systemctl enable sshd sudo systemctl start sshd sudo yum install postfix sudo systemctl enable postfix sudo systemctl start postfix sudo firewall-cmd --permanent --add-service=http sudo systemctl reload firewalld
2. Download the Omnibus package and install everything
curl -O https://downloads-packages.s3.amazonaws.com/centos-7.1.1503/gitlab-ce-7.10.1~omnibus.2-1.x86_64.rpm sudo rpm -i gitlab-ce-7.10.1~omnibus.2-1.x86_64.rpm
3. Configure and start GitLab
sudo gitlab-ctl reconfigure
4. Browse to the hostname and login
ブラウザチェック
Username: root
Password: 5iveL!fe
ではインストール作業
1.関連ツールのインストールと起動設定
gitlabの動作で使用しているツールのインストールを行います。
openssh-server:
通信データーを暗号化してリモートアクセスを安全に行うためのプロトコル SSH(Secure SHell)を利用するためのソフトウェア
postfix:
オープンソースソフトウェアのメール転送エージェント
インストール
sudo yum install openssh-server sudo yum install postfix
openssh-serverの起動・再起動時の起動設定をonにします
sudo systemctl enable postfix sudo systemctl start postfix
postfixの起動・再起動時の起動設定をonにします
sudo systemctl enable sshd sudo systemctl start sshd
2.gitlabインストール
gitlabのrpmファイルをダウンロードします
curl -O https://downloads-packages.s3.amazonaws.com/centos-7.1.1503/gitlab-ce-7.10.1~omnibus.2-1.x86_64.rpm
インストール(rpm実行)します
sudo rpm -i gitlab-ce-7.10.1~omnibus.2-1.x86_64.rpm
3.設定ファイルの編集
gitlabの設定ファイル「/etc/gitlab/gitlab.rb」を編集し、各設定を行います。
公式ドキュメントの手順に抜けているが、これがないと次の「gitlab-ctl reconfigure」がうまくいかない?と思います。
sudo vim /etc/gitlab/gitlab.rb
「/etc/gitlab/gitlab.rb」を編集
external_url 'http://[ipアドレス/ホスト名]:8000' gitlab_rails['gravatar_enabled'] = false
8000番ポートにしておく。80の場合apacheとかぶるため。
gitlab_rails['gravatar_enabled'] = falseはgravatar(グローバルに扱われるアバター)を無効にします。
4.ファイアウォール設定
ファイアウォールを切っている場合はとくに不要です。
CentOS7になってiptablesの設定にはfirewalldを使用するようになっています。
sudo firewall-cmd --permanent --add-port=8000/tcp sudo systemctl reload firewalld
※8000ポートの追加
5.設定ファイルの反映と関連処理の実行
gitlabではchefというプロビジョニングを実行してgitlabに必要なnginxのインストールや環境設定などいろいろ行っています。
「3.設定ファイルの編集」で設定した情報もここで設定値を反映します。
sudo gitlab-ctl reconfigure
5.gitlab起動
起動
sudo gitlab-ctl start
———その他オプション————–
停止
sudo gitlab-ctl stop
ステータス確認
sudo gitlab-ctl status
——————————–
6.ブラウザよりgitlabページの表示
http://[ipアドレス/ホスト名]:8000
でアクセスします
ログインユーザとパスはドキュメントに記載している通りです
Username: root
Password: 5iveL!fe
※パスワード変更画面になるので、自分のパスワードに変更したほうが安全です
ここまででインストール作業完了です。
Gitlabをサブディレクトリでアクセスしたら遅くなったので対応方法をメモ
[CentOS]Gitlabをサブディレクトリでアクセスできるようにする(およそ3分作業)
サブディレクトリでアクセス出来るように対応したら、速度が激減したので対応したやり方を忘れないようにメモ
vagrant,vpsなどにインストールされているcentosでも同作業。
もともとサブディレクとでなく、ルート直下「http://[ipアドレス/ホスト名]:8000」で動作させていた時は、ストレスを感じない速度だったが、サブディレクトリ対応「http://[ipアドレス/ホスト名]:8000/gitlab」をした途端に重くなった。
gitlabのページを開く時、別ページに遷移するときが全て時間がかかるようになった。
解決策
gitla-http.confファイルの編集で速度が元にもどった
参考:
http://qiita.com/tnamao/items/a7bb1ca868b594eaf788
gitla-http.confの編集
vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
< 修正1 >
下記箇所をすべてコメントアウト対応
#location ~ ^/(assets)/ { # root /opt/gitlab/embedded/service/gitlab-rails/public; # gzip_static on; # to serve pre-gzipped version # expires max; # add_header Cache-Control public; #}
< 修正2 >
下記locationの場所を修正
変更前
location / { ## Serve static files from defined root folder. ## @gitlab is a named location for the upstream fallback, see below. try_files $uri $uri/index.html $uri.html @gitlab; }
変更後
location /gitlab { ## Serve static files from defined root folder. ## @gitlab is a named location for the upstream fallback, see below. alias /opt/gitlab/embedded/service/gitlab-rails/public; try_files $uri $uri/index.html $uri.html @gitlab; }
ここまでの対応を行い、速度が改善された。理由は・・・・わからない。
< 修正2 > でいうとaliasを付けて速度が改善したなら、ファイルのルートの場所がわからず探しているのに時間がかかっていたのか・・・
不明。
Gitlabをサブディレクトリでアクセスできるようにする方法をメモ
[CentOS]Gitlabを公式ドキュメントに従いインストールする(およそ3分作業)
上記よりGitlabのインストールが終わったので、それをサブディレクトリ「http://[ipアドレス/ホスト名]:8000/gitlab」でアクセスできるようにする
vagrant,vpsなどにインストールされているcentosでも同作業。
手順の確認
application.rb(全体設定)に手順が記載されている。
まず中身の確認
cat /opt/gitlab/embedded/service/gitlab-rails/config/application.rb
結果: ※ 上部に記載されている
# Note that following settings need to be changed for this to work. # 1) In your application.rb file: config.relative_url_root = "/gitlab" # 2) In your gitlab.yml file: relative_url_root: /gitlab # 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab" # 4) In ../gitlab-shell/config.yml: gitlab_url: "http://127.0.0.1/gitlab" # 5) In lib/support/nginx/gitlab : do not use asset gzipping, remove block starting with "location ~ ^/(assets)/"
※5)はやらなくてよい
1.gitlabの設定情報を反映させる
設定内容を反映させる
gitlab-ctl reconfigure
このコマンドを実行すると設定ファイルの上書きが行われる。そのためこれ移行したの手順でファイルを編集したあとに「reconfigure」を実行すると内容が消えてしまうファイルがあるため、再度行わない事。
2.application.rbファイルの編集
「1) In your application.rb file: config.relative_url_root = “/gitlab”」の実行
application.rb(全体設定)の設定ファイルを開く
vim /opt/gitlab/embedded/service/gitlab-rails/config/application.rb
config.relative_url_rootをコメントアウト(#)を消して有効にする
config.relative_url_root = "/gitlab"
※手元環境だと65行目
3.gitlab.ymlファイルの編集
「2) In your gitlab.yml file: relative_url_root: /gitlab」の実行
gitlabの設定ファイルを開く
vim /var/opt/gitlab/gitlab-rails/etc/gitlab.yml
relative_url_rootをコメントアウト(#)を消して有効にする
relative_url_root: /gitlab
※手元環境だと24行目
4.unicon.rbファイルの編集
「3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT'] = “/gitlab”」の実行
uniconはrailsを動作させるためのサーバになり、gitlabはuniconで動作している
uniconの設定ファイルを開く
vim /var/opt/gitlab/gitlab-rails/etc/unicorn.rb
下記コードの何れかに追記(何処でも良いと思われるが一番上部に設置)
ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"
5.config.ymlファイルの編集
「4) In ../gitlab-shell/config.yml: gitlab_url: “http://127.0.0.1/gitlab”」の実行
configファイルを開く
vim /var/opt/gitlab/gitlab-shell/config.yml
gitlab_urlへサブディレクトリのgitlabを追加する
gitlab_url: "http://127.0.0.1:8080/gitlab"
※手元環境だと9行目
6.設定ファイルの反映
gitlab-ctl restart
6.ブラウザアクセス
http://[ipアドレス/ホスト名]:8000/gitlab
でアクセス出来ればOK
Gitlabを公式ドキュメントに従いインストールする方法をメモ
CentOSへgitlabをインストールする場合のメモ
vagrant,vpsなどにインストールされているcentosでも同作業。
公式サイト
https://about.gitlab.com/
手順
公式サイトのトップページより「Downloads」ボタンをクリックし、「I want to install GitLab on」でOSを選択する。
対象のOSを選択する ※今回はCentOS6とする
Download the Omnibus package and install everything
curl -O https://downloads-packages.s3.amazonaws.com/centos-6.6/gitlab-7.5.3_omnibus.5.2.1.ci-1.el6.x86_64.rpm sudo yum install openssh-server sudo yum install postfix sudo yum install cronie sudo service postfix start sudo chkconfig postfix on sudo rpm -i gitlab-7.5.3_omnibus.5.2.1.ci-1.el6.x86_64.rpm
Configure and start GitLab
sudo gitlab-ctl reconfigure sudo lokkit -s http -s ssh
1.関連ツールのインストールと起動設定
gitlabの動作で使用しているツールのインストールを行う
openssh-server:
通信データーを暗号化してリモートアクセスを安全に行うためのプロトコル SSH(Secure SHell)を利用するためのソフトウェア
postfix:
オープンソースソフトウェアのメール転送エージェント
cronie:
cronソフトウェア
インストール
sudo yum install openssh-server sudo yum install postfix sudo yum install cronie
postfixの起動・再起動時の起動設定をon
sudo service postfix start sudo chkconfig postfix on
2.gitlabインストール
gitlabのrpmファイルをダウンロード
curl -O https://downloads-packages.s3.amazonaws.com/centos-6.6/gitlab-7.5.3_omnibus.5.2.1.ci-1.el6.x86_64.rpm
インストール(rpm実行)
sudo rpm -i gitlab-7.5.3_omnibus.5.2.1.ci-1.el6.x86_64.rpm
3.設定ファイルの編集
gitlabの設定ファイル「/etc/gitlab/gitlab.rb」を編集し、各設定を行う。
公式ドキュメントの手順に抜けているが、これがないと次の「gitlab-ctl reconfigure」がうまくいかないかも。
sudo vim /etc/gitlab/gitlab.rb
「/etc/gitlab/gitlab.rb」を編集
external_url 'http://[ipアドレス/ホスト名]:8000' gitlab_rails['gravatar_enabled'] = false
8000番ポートにしておく。80の場合apacheとかぶるため。
gitlab_rails['gravatar_enabled'] = falseはgravatar(グローバルに扱われるアバター)を無効にする
4.ファイアウォール設定
ファイアウォールを切っている場合はとくに不要。
8000番ポートを開くなら「/etc/sysconfig/iptables」を編集
sudo vim /etc/sysconfig/iptables
「/etc/sysconfig/iptables」を編集
-A SERVICES -p tcp --dport 8000 -j ACCEPT
※8000ポート開放の追加
5.設定ファイルの反映と関連処理の実行
gitlabではchefというプロビジョニングを実行してgitlabに必要なnginxのインストールや環境設定などいろいろ行ってくれている。
「3.設定ファイルの編集」で設定した情報もここで設定値を反映してくれる
sudo gitlab-ctl reconfigure
5.gitlab起動
起動
sudo gitlab-ctl start
———その他オプション————–
停止
sudo gitlab-ctl stop
ステータス確認
sudo gitlab-ctl status
——————————–
6.ブラウザよりgitlabページの表示
http://[ipアドレス/ホスト名]:8000
でアクセス
ログインユーザとパスはドキュメントに記載している通り
Username: root
Password: 5iveL!fe
※パスワード変更画面になるので、自分のパスワードに変更すること
以上
coffee-break
Don't write code that useless.
1日5杯はコーヒー、カフェオレ飲みます。狭心症のため安静にします☆松本 雄貴
Kotlinでサービスリリース目指す!
iOSでチャットアプリ作成中。自然言語解析LSIを習得中
Mac / Android・iOS / Rails / Oracle
2017年 Lpic L2取得
2012年 Android技術者資格取得
2010年 OracleMasterGold10g取得
2008年 CCNAQiitaもたまに投稿
https://qiita.com/y-matsumoto東京近郊で常駐開発探してる方はこちらよりご連絡ください
SES企業でパートナー会社を探している企業様はこちらよりご連絡ください
スプリットカメラ iOS / Android
音声認識で聞いた日付から曜日当てアプリ Android
ソーシャルタイマー Android
カテゴリー
- ActiveRecord (2)
- Android (52)
- AndroidStudio (10)
- Ansible (1)
- AWS (1)
- Bash (18)
- Blog (7)
- BootStrap (1)
- CentOS (16)
- Chef (1)
- css (2)
- Eclipse (5)
- error (1)
- Facebook (2)
- Firebase (1)
- FuelPHP (16)
- Git (22)
- GitHub (3)
- Gradle (2)
- GraphAPI (1)
- Grunt (1)
- heroku (2)
- illustrator (1)
- iOS (17)
- Java (4)
- Jenkins (1)
- jQuery (3)
- Kotlin (2)
- Mac (22)
- nginx (1)
- Node.js (3)
- peco (1)
- php (5)
- Python (1)
- Rails (16)
- Ruby (11)
- shell (1)
- SNS (1)
- Swift (2)
- tmux (2)
- Vagrant (6)
- Vim (6)
- windows (2)
- WordPress (3)
- zsh (4)
- フリーランス (1)
- ライブラリ (1)
- 勉強会 (2)
- 宣伝 (1)
- 未分類 (2)
最近の投稿
- [MAC]HighSierraでgitプッシュエラー「Unable to negotiate with xxx.xxx.xxx.xxx port xx: no matching cipher found. Their offer: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se fatal: Could not read from remote repository.」
- [iOS]iOS11からFacebook,Twitter連携(シェアなど)廃止の対応方法
- [iOS]速報2017AppleSpecialEventのiOS11、iPhone8など発表内容について
- [iOS][Firebase]The default Firebase app has not yet been configured. Add `[FIRApp configure];
- [iOS]2017年9月リリースのiOS11で開発者が対応するべきこと
- 今人気の現金化サービスCASH(キャッシュ)を使ったレビュー
- [Pandoc][Mac]pandocでmarkdownからwordファイル作成
- [Android]映画サマーウォーズの聞いた日付(誕生日)から曜日当てをアプリ音声認識で簡単に実現
- [Android]起動しているActivityを取得するadb shell コマンド
- [Android][Kotlin]kotlin学習で参考になるサイト一覧
2023年12月 月 火 水 木 金 土 日 « 5月 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 アーカイブ
- 2018年5月
- 2017年9月
- 2017年8月
- 2017年7月
- 2017年6月
- 2017年5月
- 2017年2月
- 2017年1月
- 2016年12月
- 2016年7月
- 2016年6月
- 2016年1月
- 2015年12月
- 2015年11月
- 2015年10月
- 2015年9月
- 2015年8月
- 2015年7月
- 2015年6月
- 2015年5月
- 2015年4月
- 2015年3月
- 2015年2月
- 2015年1月
- 2014年12月
- 2014年11月
- 2014年6月
- 2014年5月
- 2014年4月
- 2014年3月
- 2014年2月
- 2014年1月
- 2013年12月
- 2013年11月
- 2013年9月
- 2013年8月
- 2013年7月
- 2013年6月
- 2013年5月
- 2013年4月
- 2013年3月
- 2013年2月
- 2013年1月
- 2012年12月
- 2012年10月
- 2012年5月
- 2010年6月
エントリ