Home
Packages
Forums
Wiki
GitLab
Security
AUR
Download
コンテンツにスキップ
メインメニュー
メインメニュー
サイドバーに移動
非表示
案内
メインページ
目次
コミュニティに貢献
最近の出来事
おまかせ表示
特別ページ
交流
ヘルプ
貢献
最近の更新
最近の議論
新しいページ
統計
リクエスト
ArchWiki
検索
検索
表示
アカウント作成
ログイン
個人用ツール
アカウント作成
ログイン
GitLabのソースを表示
ページ
議論
日本語
閲覧
ソースを閲覧
履歴を表示
ツール
ツール
サイドバーに移動
非表示
操作
閲覧
ソースを閲覧
履歴を表示
全般
リンク元
関連ページの更新状況
ページ情報
表示
サイドバーに移動
非表示
←
GitLab
あなたには「このページの編集」を行う権限がありません。理由は以下の通りです:
この操作は、次のグループに属する利用者のみが実行できます:
登録利用者
。
このページのソースの閲覧やコピーができます。
[[Category:バージョン管理システム]] [[en:Gitlab]] {{Related articles start}} {{Related|Gitolite}} {{Related|Ruby on Rails}} {{Related articles end}} [https://about.gitlab.com/ GitLab のホームページ] より: :''GitLab は git リポジトリの管理、コードレビュー、イシュートラッキング、アクティビティフィード、wiki を提供します。エンタープライズは自社運用な GitLab をインストールして LDAP や Active Directory サーバーと接続してセキュアな認証を行います。単一の GitLab サーバーだけで 25,000 以上のユーザーを管理することができますが、サーバーを複数用意すれば更に多数のユーザーを使えるようにすることが可能です。'' 実際に動作するサンプル版が [https://gitlab.com/ GitLab.com] に存在します。 == インストール == {{Note| * RVM を使いたい場合はインストールする前に [[#rvm で GitLab を実行]] を参照してください。 * この記事ではまず HTTPS を使わないで GitLab をインストール・設定する方法を説明します。HTTPS が必要な場合は [[#高度な設定]] を参照して SSL をセットアップしてください。}} GitLab はデータベースバックエンドを必要します。同一のマシン上でデータベースを実行する場合、先に [[MySQL]] か [[PostgreSQL]] をインストールしてください。 {{Pkg|gitlab}} パッケージを[[インストール]]してください。 メール通知を受け取るには、メールサーバーをインストール・設定する必要があります。詳しくは次のカテゴリを参照: [[:カテゴリ:メールサーバー]]。 == 設定 == === 設定ファイル === {{Pkg|gitlab}} パッケージは GitLab のファイルを Linux の標準的な慣習にそって以下のようにインストールします: {| class="wikitable" ! 説明 ! [https://github.com/gitlabhq/gitlabhq/blob/6-5-stable/doc/install/installation.md GitLab 公式] ! {{Pkg|gitlab}} |---------------------------------------------------------- | GitShell の設定ファイル | {{ic|/home/git/gitlab-shell/config.yml}} | {{ic|/etc/webapps/gitlab-shell/config.yml}} |---------------------------------------------------------- | GitLab の設定ファイル | {{ic|/home/git/gitlab/config/gitlab.yml}} | {{ic|/etc/webapps/gitlab/gitlab.yml}} |---------------------------------------------------------- | ユーザー (ホームディレクトリ) | {{ic|git}} ({{ic|/home/git}}) | {{ic|gitlab}} ({{ic|/var/lib/gitlab}}) |} {{tip|[[Arch Build System]] が使用できるのであれば、PKGBUILD や関連するファイルを編集することで gitlab のホームディレクトリを好きな場所に変更できます。}} ===基本設定=== ====GitLab Shell==== {{Note|同一のホスト上で GitLab をホストする場合 {{ic|gitlab_url}} はデフォルト値のままで問題ありません。}} {{ic|/etc/webapps/gitlab-shell/config.yml}} を編集して {{ic|gitlab_url:}} で適当な url とポートを設定してください: {{hc|/etc/webapps/gitlab-shell/config.yml|2= # GitLab user. git by default user: gitlab # Url to gitlab instance. Used for api calls. Should end with a slash. # Default: http://localhost:8080/ # You only have to change the default if you have configured Unicorn # to listen on a custom port, or if you have configured Unicorn to # only listen on a Unix domain socket. gitlab_url: "http://localhost:8080/" # <<-- right here http_settings: # user: someone # password: somepass ... }} ポートやホストネームがデフォルト値と違う場合は {{ic|/usr/share/webapps/gitlab/unicorn.rb}} の設定を更新してください: {{hc|/etc/webapps/gitlab/unicorn.rb|2= listen "127.0.0.1:8080", :tcp_nopush => true # <<-- right here }} ====GitLab==== {{ic|/etc/webapps/gitlab/gitlab.yml}} を編集して以下のパラメータを設定してください: {{Tip|ホストネームとポートは {{ic|git clone http://hostname:port}} などとして使われます。}} '''ホストネーム:''' {{ic|gitlab:}} セクションで {{ic|host:}} を設定 - {{ic|localhost}} を {{ic|yourdomain.com}} に置き換えます ('''ノート:''' 'http://' や末尾のスラッシュは付けません) - 完全修飾ドメイン名を使ってください。 '''ポート:''' {{ic|port:}} は紛らわしいかもしれません。gitlab サーバー (unicorn) が動作するポートではありません。ユーザーがブラウザを使って最初にアクセスするときのポートです。ブラウザから 'yourdomain.com' にアクセスするようにしたい場合、ドメイン名にポート番号は基本的に付けないので、{{ic|port:}} は {{ic|80}} のままにしておきます。ブラウザに 'yourdomain.com:3425' などと入力させるときのみ、{{ic|port:}} を {{ic|3425}} と設定します。また、ウェブサーバーの設定も変更して、設定したポートを使うようにしてください。 '''タイムゾーン (任意):''' {{ic|time_zone:}} パラメータは任意ですが、GitLab アプリケーションのゾーンを強制することができます。 上記は GitLab を動作させるのに最小限必要な設定です。勇気がある人はコメントを読んで必要に応じて他の設定もカスタマイズしてください。 === 詳細設定 === ==== データベースバックエンド ==== Gitlab を実行する前にデータベースバックエンドが必要になります。現在 GitLab は [[MariaDB]] と [[PostgreSQL]] をサポートしています。デフォルトでは、GitLab は MySQL を使うことになっています。PostgreSQL を使用する場合、特別な設定が必要です。 ==== MariaDB ==== MySQL (MariaDB) をセットアップする場合、{{ic|gitlabhq_production}} という名前のデータベースと、そのデータベースの全ての権限を持ったユーザーを作成してください (デフォルト: {{ic|gitlab}}): {{hc|$ mysql -u root -p|2= mysql> CREATE DATABASE `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'password'; mysql> GRANT ALL ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; mysql> \q }} 新しいユーザーで新しいデータベースへの接続を試行: $ mysql -u '''gitlab''' -p -D gitlabhq_production 次に {{ic|/etc/webapps/gitlab/database.yml}} を開いて {{ic|gitlabhq_production}} の {{ic|username:}} と {{ic|password:}} を設定してください: {{hc|/etc/webapps/gitlab/database.yml| # # PRODUCTION # production: adapter: mysql2 encoding: utf8 reconnect: false collation: utf8_general_ci database: gitlabhq_production pool: 10 username: '''username''' password: '''"password"''' # host: localhost # socket: /run/mysqld/mysqld.sock # If running MariaDB as socket ... }} ファイルは誰からでも読み込めるようにするべきではありません。{{ic|gitlab}} ユーザーのプロセスだけが読み書きできるようにします: # chmod 600 /etc/webapps/gitlab/database.yml # chown gitlab:gitlab /etc/webapps/gitlab/database.yml MySQL データベースの作成・管理に関する詳しい情報は [https://mariadb.org/docs/ MariaDB のドキュメント] や [https://github.com/gitlabhq/gitlabhq/blob/6-5-stable/doc/install/installation.md GitLab 公式の (汎用) インストールガイド] を見てください。 ==== PostgreSQL ==== PostgreSQL にログインして {{ic|gitlabhq_production}} データベースとユーザーを作成してください。{{ic|your_username_here}} と {{ic|your_password_here}} は実際の値に置き換えてください: # psql -d template1 {{bc|1= template1=# CREATE USER your_username_here WITH PASSWORD 'your_password_here'; template1=# ALTER USER your_username_here SUPERUSER; template1=# CREATE DATABASE gitlabhq_production OWNER your_username_here; template1=# \q }} {{Note|ユーザーをスーパーユーザーとして作成することで GitLab は「スマート」になり拡張をインストールします。[[PostgreSQL]] ではスーパーユーザーだけが拡張のインストールを許可されています。}} 新しいユーザーで新しいデータベースに接続してデータベースが使えることを確認: # psql -d gitlabhq_production 続行する前に PostgreSQL テンプレートファイルをコピーしてください (デフォルトの MySQL 設定ファイルを上書きします): # cp /usr/share/doc/gitlab/database.yml.postgresql /etc/webapps/gitlab/database.yml 新しい {{ic|/etc/webapps/gitlab/database.yml}} を開いて {{ic|username:}} と {{ic|password:}} の値を設定します。例: {{hc|/etc/webapps/gitlab/database.yml| # # PRODUCTION # production: adapter: postgresql encoding: unicode database: gitlabhq_production pool: 10 username: your_username_here password: "your_password_here" # host: localhost # port: 5432 # socket: /tmp/postgresql.sock ... }} {{ic|/etc/webapps/gitlab/database.yml}} に記載されている他のデータベースの設定について心配する必要はありません。GitLab を使うにはプロダクションデータベースだけをセットアップすれば十分です。 最後に、{{ic|/usr/lib/systemd/system/gitlab.target}} と {{ic|/usr/lib/systemd/system/gitlab-unicorn.service}} を開いて {{ic|mysql.service}} の記述を全て {{ic|postgresql.service}} に変えてください。 ==== ファイアウォール ==== [[iptables]] ファイアウォールを通り抜けて Gitlab に直接アクセスできるようにしたい場合、ポートとネットワークアドレスを調整してください: # iptables -A tcp_inbound -p TCP -s '''192.168.1.0/24''' --destination-port '''80''' -j ACCEPT API のアクセスを有効にするには: # iptables -A tcp_inbound -p TCP -s '''192.168.1.0/24''' --destination-port '''8080''' -j ACCEPT ルーターを使っている場合、WAN からアクセスできるようにしたいとき、GitLab サーバーを実行しているホストにポートを転送するようにしてください。 ==== Satellites のアクセス権限 ==== {{ic|satellites}} フォルダには以下のパーミッションを設定してください: # chmod 750 /var/lib/gitlab/satellites ==== Gitlab データベースの初期化 ==== データベースを作成する前に Redis サーバーを起動: # systemctl start redis # systemctl enable redis 以下のコマンドで bundler をインストールして必要な gem をインストールします: # export PATH=$PATH:/var/lib/gitlab/.gem/ruby/2.3.0/bin # sudo -u gitlab -H gem install bundler --no-document # cd /usr/share/webapps/gitlab # sudo -u gitlab -H bundle install {{Warning|GitLab は {{ic|bundle}} コマンドを必要とします。忘れずにインストールしてください。}} {{Note|'gitlab' ユーザーで bundle が存在しないというエラーが表示される場合、おそらく ruby が {{ic|/usr/lib}} などの読み込みできないディレクトリにインストールされていることが原因です。以下のコマンドで解決できます: {{bc|<nowiki> su - gitlab -s /bin/sh -c "export PATH=$PATH:/var/lib/gitlab/.gem/ruby/2.3.0/bin; gem install bundler --no-document" su - gitlab -s /bin/sh -c "export PATH=$PATH:/var/lib/gitlab/.gem/ruby/2.3.0/bin; cd /usr/share/webapps/gitlab; bundle install" su - gitlab -s /bin/sh -c "export PATH=$PATH:/var/lib/gitlab/.gem/ruby/2.3.0/bin; cd /usr/share/webapps/gitlab; bundle exec rake gitlab:setup RAILS_ENV=production" su - gitlab -s /bin/sh -c "export PATH=$PATH:/var/lib/gitlab/.gem/ruby/2.3.0/bin; cd /usr/share/webapps/gitlab; bundle exec rake assets:precompile RAILS_ENV=production" </nowiki>}} }} データベースを初期化して高度な機能を有効化: # cd /usr/share/webapps/gitlab # su - gitlab -s /bin/sh -c "cd '/usr/share/webapps/gitlab'; bundle exec rake gitlab:setup RAILS_ENV=production" {{bc|<nowiki> Missing `db_key_base` for 'production' environment. The secrets will be generated and stored in `config/secrets.yml` This will create the necessary database tables and seed the database. You will lose any previous data stored in the database. Do you want to continue (yes/no)? yes gitlabhq_production already exists -- enable_extension("plpgsql") -> 0.0009s -- create_table("abuse_reports", {:force=>true}) -> 0.0300s -- create_table("application_settings", {:force=>true}) -> 0.0116s ... Administrator account created: login.........root password......5iveL!fe </nowiki>}} アセットをコンパイル: # su - gitlab -s /bin/sh -c "cd '/usr/share/webapps/gitlab'; bundle exec rake assets:precompile RAILS_ENV=production" 最後に、{{ic|/etc/webapps/gitlab/secret}} にランダムな16進数の文字列が書かれていることを確認してください。 ==== Git ユーザーの設定 ==== {{Note|以下は {{ic|/usr/share/webapps/gitlab/config/gitlab.yml}} で定義した {{ic|user}} や {{ic|email_from}} と一致している必要があります。}} # cd /usr/share/webapps/gitlab # sudo -u gitlab -H git config --global user.name "GitLab" # sudo -u gitlab -H git config --global user.email "example@example.com" # sudo -u gitlab -H git config --global core.autocrlf "input" ==== 修飾ビットの調整 ==== (The gitlab check won't pass if the user and group ownership isn't configured properly) # chmod -R ug+rwX,o-rwx /var/lib/gitlab/repositories/ # chmod -R ug-s /var/lib/gitlab/repositories # find /var/lib/gitlab/repositories/ -type d -print0 | xargs -0 chmod g+s == GitLab の起動とテスト == {{note|何か問題が発生する場合は [[#トラブルシューティング]] や {{ic|/usr/share/webapps/gitlab/log}} ディレクトリのログファイルを見てください。}} systemd から新しいデーモンのユニットファイルを認識させる: # systemctl daemon-reload [[MySQL]] や [[PostgreSQL]] と Redis が正しく実行・設定されていることを確認してください。 GitLab が {{ic|redis}} を正しくロードできない場合など、必要であれば [[#Redis で Unix ソケットを使う]] を見てください。 データベースバックエンドを起動した後、GitLab とウェブサーバー (Unicorn) を起動します: # systemctl start gitlab-sidekiq gitlab-unicorn 以下のコマンドを使うことで正しく設定がされているかどうか確認できます: # cd /usr/share/webapps/gitlab # sudo -u gitlab bundle exec rake gitlab:env:info RAILS_ENV=production # sudo -u gitlab bundle exec rake gitlab:check RAILS_ENV=production {{note|gitlab:env:info と gitlab:check コマンドは git に関する致命的なエラーを出力しますが、それで問題ありません。}} {{hc|<nowiki>$ sudo -u gitlab bundle exec rake gitlab:env:info RAILS_ENV=production</nowiki>|<nowiki> fatal: Not a git repository (or any of the parent directories): .git System information System: Arch rolling Current User: gitlab Using RVM: no Ruby Version: 2.2.3p173 Gem Version: 2.4.5.1 Bundler Version:1.10.6 Rake Version: 10.4.2 Sidekiq Version:3.3.0 GitLab information Version: 7.14.0 Revision: fatal: Not a git repository (or any of the parent directories): .git Directory: /usr/share/webapps/gitlab DB Adapter: mysql2 URL: http://gitlab.arch HTTP Clone URL: http://gitlab.arch/some-project.git SSH Clone URL: git@gitlab.arch:some-project.git Using LDAP: no Using Omniauth: no GitLab Shell Version: 2.6.4 Repositories: /var/lib/gitlab/repositories/ Hooks: /usr/share/webapps/gitlab-shell/hooks/ Git: /usr/bin/git </nowiki>}} {{Note| {{ic|gitlab:check}} は initscripts が存在しないというエラーを吐きます。問題はありません。代わりに [[systemd]] のサービスファイルが使われます (GitLab は systemd を認識しません)。}} {{hc|<nowiki>$ sudo -u gitlab bundle exec rake gitlab:check RAILS_ENV=production</nowiki>|<nowiki> fatal: Not a git repository (or any of the parent directories): .git Checking Environment ... Git configured for gitlab user? ... yes Has python2? ... yes python2 is supported version? ... yes Checking Environment ... Finished Checking GitLab Shell ... GitLab Shell version >= 1.7.9 ? ... OK (1.8.0) Repo base directory exists? ... yes Repo base directory is a symlink? ... no Repo base owned by gitlab:gitlab? ... yes Repo base access is drwxrws---? ... yes update hook up-to-date? ... yes update hooks in repos are links: ... can't check, you have no projects Running /srv/gitlab/gitlab-shell/bin/check Check GitLab API access: OK Check directories and files: /srv/gitlab/repositories: OK /srv/gitlab/.ssh/authorized_keys: OK Test redis-cli executable: redis-cli 2.8.4 Send ping to redis server: PONG gitlab-shell self-check successful Checking GitLab Shell ... Finished Checking Sidekiq ... Running? ... yes Number of Sidekiq processes ... 1 Checking Sidekiq ... Finished Checking LDAP ... LDAP is disabled in config/gitlab.yml Checking LDAP ... Finished Checking GitLab ... Database config exists? ... yes Database is SQLite ... no All migrations up? ... fatal: Not a git repository (or any of the parent directories): .git yes GitLab config exists? ... yes GitLab config outdated? ... no Log directory writable? ... yes Tmp directory writable? ... yes Init script exists? ... no Try fixing it: Install the init script For more information see: doc/install/installation.md in section "Install Init Script" Please fix the error above and rerun the checks. Init script up-to-date? ... can't check because of previous errors projects have namespace: ... can't check, you have no projects Projects have satellites? ... can't check, you have no projects Redis version >= 2.0.0? ... yes Your git bin path is "/usr/bin/git" Git version >= 1.7.10 ? ... yes (1.8.5) Checking GitLab ... Finished </nowiki>}} システムの起動時に GitLab を自動的に実行したいときは {{ic|gitlab.target}}, {{ic|gitlab-sidekiq}}, {{ic|gitlab-unicorn}} サービスを有効化してください。 そして http://localhost:8080 や http://yourdomain.com をブラウザで開いてデフォルトのユーザー情報を使ってログインすることで GitLab インスタンスをテストしてください: {{bc| username: root password: 5iveL!fe }} {{note|1=gitlab を動作させるマシンとブラウザを使用するマシンが異なる場合、プロキシを使わなくてもセットアップがテストできるように unicorn.rb を修正してください。以下の行を: <pre>listen "127.0.0.1:8080, :tcp_nopush => true</pre> 以下のように置き換えてください: <pre>listen "example.yourhost.com:8080, :tcp_nopush => true</pre> }} == 高度な設定 == === SSH 接続のカスタマイズ === SSH を標準以外のポートで実行している場合、GitLab ユーザーの SSH 設定を変更する必要があります: {{hc|/var/lib/gitlab/.ssh/config|2= host localhost # Give your setup a name (here: override localhost) user gitlab # Your remote git user port 2222 # Your port number hostname 127.0.0.1; # Your server name or IP }} {{ic|/etc/webapps/gitlab/gitlab.yml}} ファイルのオプション (例: ssh_user, ssh_host, admin_uri) も変更してください。 === HTTPS/SSL === ==== GitLab 設定の変更 ==== {{ic|/etc/webapps/gitlab/shell.yml}} を修正して GitLab サイトを {{ic|https://}} から始まる URL に変えてください。{{ic|/etc/webapps/gitlab/gitlab.yml}} を修正して {{ic|https:}} を {{ic|true}} に設定してください。 ==== Let's Encrypt ==== URL を検証する際、Let's Encrypt は {{ic|<nowiki>https://gitlab.</nowiki>''YOUR_SERVER_FQDN''/.well-known/''A_LONG_ID''}} のように gitlab サーバーにアクセスできるかどうか試行します。しかしながら、gitlab の設定によって、{{ic|gitlab.''YOUR_SERVER_FQDN''}} へのリクエストはプロキシ (gitlab-workhorse) に全て転送されるため、URL の確認が失敗します。 Let's Encrypt の webroot を使用することでこの問題を回避することが可能です。webroot を {{ic|/srv/http/letsencrypt/}} に設定してください。 さらに、Let's Encrypt の gitlab へのリクエストが全て webroot に転送されるように、以下の記述を追加します: {{hc|/etc/http/conf/extra/gitlab.conf| Alias "/.well-known" "/srv/http/letsencrypt/.well-known" RewriteCond %{REQUEST_URI} !/\.well-known/.* }} ===ウェブサーバーの設定=== Gitlab に組み込まれている http サーバー、Unicorn を使うかわりに別のウェブサーバーで Gitlab を使いたい場合、以下の手順に従ってください。 ===== Node.js ===== Node.js の http-master を使用することでポート 8080 で動作している GitLab アプリケーションにトラフィックを転送する http プロキシをポート 443 に設定することができます。ドメインの OpenSSL 鍵を作成して CA 証明書を取得 (もしくは自己署名) した後に、https://github.com/CodeCharmLtd/http-master を読んでください。HTTPS を使って GitLab にリクエストを転送する方法が載っています。http-master は [https://github.com/nodejitsu/node-http-proxy node-http-proxy] を元に作成されています。 ====Nginx と unicorn==== =====AUR インストール===== [[Nginx]] をセットアップして、以下のディレクトリを作成してください (存在しない場合): # mkdir /etc/nginx/servers-available # mkdir /etc/nginx/servers-enabled {{Note|{{ic|localhost:8080}} を gitlab のアドレスに {{ic|example.com}} をサーバーの名前に置き換える必要があります。}} {{Tip|SSL を有効にする前に [[Nginx#SSL]] を見てください。}} 以下の内容で {{ic|/etc/nginx/servers-available/gitlab}} ファイルを作成: {{hc|/etc/nginx/servers-available/gitlab|2= # Created by: Sameer Naik # Contributor: francoism90 # Source: https://gist.github.com/sameersbn/becd1c976c3dc4866ef8 upstream gitlab { server localhost:8080 fail_timeout=0; } server { listen 80; #listen 443 ssl; # uncomment to enable ssl keepalive_timeout 70; server_name example.com server_tokens off; #ssl_certificate ssl/example.com.crt; #ssl_certificate_key ssl/example.com.key; charset utf-8; root /dev/null; # Increase this if you want to upload larger attachments client_max_body_size 20m; location / { proxy_read_timeout 300; proxy_connect_timeout 300; proxy_redirect off; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Ssl on; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Frame-Options SAMEORIGIN; proxy_pass http://localhost:8080; } } }} {{ic|/etc/nginx/nginx.conf}} の {{ic|http}} ブロックの末尾に以下の行があることを確認してください: include servers-enabled/*; {{ic|github}} の設定を有効化: # ln -s /etc/nginx/servers-available/gitlab /etc/nginx/servers-enabled/gitlab 新しい設定を確認: # nginx -t 最後に {{ic|gitlab.target}}, {{ic|resque.target}}, {{ic|nginx.service}} を再起動してください。 =====手動インストール===== AUR を使わなかった場合、{{ic|/usr/lib/support/nginx/gitlab}} を {{ic|/etc/nginx/sites-available/}} にコピーする必要があります。 次のコマンドを実行して nginx を設定してください: # ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab {{ic|/etc/nginx/sites-enabled/gitlab}} を編集して YOUR_SERVER_IP と YOUR_SERVER_FQDN を Gitlab をホストするサーバーの IP アドレスと完全修飾ドメイン名に置き換えてください。 {{ic|/etc/nginx/nginx.conf}} の {{ic|http}} ブロックの末尾に以下の行があることを確認してください: include sites-enabled/*; {{ic|github}} の設定を有効化: # ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab 新しい設定を確認: # nginx -t 最後に {{ic|gitlab.target}}, {{ic|resque.target}}, {{ic|nginx.service}} を再起動してください。 ====Apache と unicorn==== [[公式リポジトリ]]から {{Pkg|apache}} を[[インストール]]してください。 =====Unicorn の設定===== 公式のインストールガイドに書かれているように、unicorn の設定ファイルをコピーしてください: # sudo -u git -H cp /usr/share/webapps/gitlab/config/unicorn.rb.example /usr/share/webapps/gitlab/config/unicorn.rb {{ic|config/unicorn.rb}} を編集し以下の行をアンコメントして listen ポートを追加します: listen "127.0.0.1:8080" {{Tip|カスタムポートを設定することもできます。Apache のバーチャルホストでも忘れずに設定してください。下を参照。}} =====Gitlab のバーチャルホストの作成===== Gitlab のバーチャルホストの設定ファイルを作成して以下の行を調整して挿入してください。ssl セクションについては [[LAMP#TLS/SSL]] を参照。SSL が必要ないときは、削除してください。SSL バーチャルホストは汎用の IP ではなく特定の IP を必要とします。Unicorn のカスタムポートを設定している場合、BalanceMember 行で忘れずに設定してください。 [https://gitlab.com/gitlab-org/gitlab-recipes/blob/079f70dd2c091434a8dd04ed5b1a0d0e937cd361/web-server/apache/gitlab-ssl-apache2.4.conf サンプル] を使って開始できます。 =====ホストの有効化と unicorn の起動===== Gitlab のバーチャルホストを有効化して [[Apache]] をリロード: {{hc|/etc/httpd/conf/httpd.conf| Include /etc/httpd/conf/extra/gitlab.conf}} Apache の {{ic|gitlab.conf}} ファイルをコピー: # cp /etc/webapps/gitlab/apache.conf.example /etc/httpd/conf/extra/gitlab.conf 最後に {{ic|gitlab-unicorn.service}} を[[起動]]してください。 === Redis === デフォルトとは異なる構成で Redis を使用するときは (アドレスやポート、Unix ソケットなどが異なる場合)、''REDIS_URL'' 環境変数を正しく設定する必要があります。systemd サービスファイルを拡張することで設定できます。{{ic|/etc/systemd/system/gitlab-unicorn.service.d/redis.conf}} ファイルを作成して ''REDIS_URL'' 環境変数を挿入してください: [Service] Environment=REDIS_URL=unix:///run/gitlab/redis.sock ==== Redis で Unix ソケットを使う ==== ソケットを listen するように Redis を設定している場合、デフォルト設定を修正するべきです: {{hc|/etc/redis.conf|2= ... # Accept connections on the specified port, default is 6379. # If port 0 is specified Redis will not listen on a TCP socket. port 0 ... # By default Redis listens for connections from all the network interfaces # available on the server. It is possible to listen to just one or multiple # interfaces using the "bind" configuration directive, followed by one or # more IP addresses. # # Examples: # # bind 192.168.1.100 10.0.0.1 bind 127.0.0.1 # Specify the path for the Unix socket that will be used to listen for # incoming connections. There is no default, so Redis will not listen # on a unix socket when not specified. # unixsocket /var/run/redis/redis.sock unixsocketperm 770 }} {{ic|/var/run/redis}} ディレクトリを作成して適切なパーミッションを設定: # mkdir /var/run/redis # chown redis:redis /var/run/redis # chmod 755 /var/run/redis {{ic|git}} と {{ic|gitlab}} ユーザーを {{ic|redis}} グループに追加: # usermod -a -G redis git # usermod -a -G redis gitlab {{ic|/etc/webapps/gitlab-shell/config.yml}} と {{ic|/etc/webapps/gitlab/resque.yml}} ファイルを修正: {{hc|/etc/webapps/gitlab/resque.yml|2= development: unix:/var/run/redis/redis.sock test: unix:/run/redis/redis.sock production: unix:/run/redis/redis.sock }} {{hc|/etc/webapps/gitlab-shell/config.yml|2= ... # Redis settings used for pushing commit notices to gitlab redis: bin: /usr/bin/redis-cli host: 127.0.0.1 port: 6379 # pass: redispass # Allows you to specify the password for Redis database: 5 # Use different database, default up to 16 socket: /var/run/redis/redis.sock # uncomment this line namespace: resque:gitlab ... }} 最後に {{ic|redis}}, {{ic|gitlab-sidekiq}}, {{ic|gitlab-unicorn}} サービスを再起動してください。 詳しくは issue [https://github.com/gitlabhq/gitlabhq/issues/6100 #6100] を見てください。 === Gitlab-workhorse === 8.0 から GitLab は Git の push や pull などの巨大な HTTP リクエストで特別な HTTP サーバー {{ic|gitlab-workhorse}} を使用します。SSH の代わりに workhorse を使いたい場合、{{AUR|gitlab-workhorse}} パッケージをインストールして、{{ic|gitlab-workhorse.service}} を有効化し、ウェブサーバーを設定してください。 ==便利なヒント== ===Rake の警告の修正=== gitlab プロジェクトで rake タスクを実行すると、次のエラーが発生します: {{ic|fatal: Not a git repository (or any of the parent directories): .git}}。これは bundle のバグなので、無視してもかまいません。エラーを消したい場合は、以下を実行してください: {{bc|1= # cd /usr/share/webapps/gitlab # sudo -u gitlab git init # sudo -u gitlab git commit -m "initial commit" --allow-empty }} ===/var のフック=== {{bc|1= # mkdir -m700 /var/log/gitlab /var/tmp/gitlab # chown gitlab:gitlab /var/log/gitlab /var/tmp/gitlab # sudo -u gitlab -i # cd ~/gitlab # d=log; mv $d/* /var/$d/gitlab; rm -f $d/.gitkeep; rm -r $d && ln -s /var/$d/gitlab $d # d=tmp; mv $d/* /var/$d/gitlab; rm -f $d/.gitkeep; rm -r $d && ln -s /var/$d/gitlab $d }} ===隠しオプション=== Gitlab のホームディレクトリに移動して: # cd /usr/share/webapps/gitlab 次を実行: {{hc|<nowiki># rake -T | grep gitlab</nowiki>|<nowiki> rake gitlab:app:check # GITLAB | Check the configuration of the GitLab Rails app rake gitlab:backup:create # GITLAB | Create a backup of the GitLab system rake gitlab:backup:restore # GITLAB | Restore a previously created backup rake gitlab:check # GITLAB | Check the configuration of GitLab and its environment rake gitlab:cleanup:block_removed_ldap_users # GITLAB | Cleanup | Block users that have been removed in LDAP rake gitlab:cleanup:dirs # GITLAB | Cleanup | Clean namespaces rake gitlab:cleanup:repos # GITLAB | Cleanup | Clean repositories rake gitlab:env:check # GITLAB | Check the configuration of the environment rake gitlab:env:info # GITLAB | Show information about GitLab and its environment rake gitlab:generate_docs # GITLAB | Generate sdocs for project rake gitlab:gitlab_shell:check # GITLAB | Check the configuration of GitLab Shell rake gitlab:import:all_users_to_all_groups # GITLAB | Add all users to all groups (admin users are added as owners) rake gitlab:import:all_users_to_all_projects # GITLAB | Add all users to all projects (admin users are added as masters) rake gitlab:import:repos # GITLAB | Import bare repositories from gitlab_shell -> repos_path into GitLab project instance rake gitlab:import:user_to_groups[email] # GITLAB | Add a specific user to all groups (as a developer) rake gitlab:import:user_to_projects[email] # GITLAB | Add a specific user to all projects (as a developer) rake gitlab:satellites:create # GITLAB | Create satellite repos rake gitlab:setup # GITLAB | Setup production application rake gitlab:shell:build_missing_projects # GITLAB | Build missing projects rake gitlab:shell:install[tag,repo] # GITLAB | Install or upgrade gitlab-shell rake gitlab:shell:setup # GITLAB | Setup gitlab-shell rake gitlab:sidekiq:check # GITLAB | Check the configuration of Sidekiq rake gitlab:test # GITLAB | Run all tests rake gitlab:web_hook:add # GITLAB | Adds a web hook to the projects rake gitlab:web_hook:list # GITLAB | List web hooks rake gitlab:web_hook:rm # GITLAB | Remove a web hook from the projects rake setup # GITLAB | Setup gitlab db </nowiki>}} ===バックアップとリストア=== gitlab システムのバックアップを作成: # sudo -u gitlab -H rake RAILS_ENV=production gitlab:backup:create 先に作成したバックアップファイル {{ic|/home/gitlab/gitlab/tmp/backups/20130125_11h35_1359131740_gitlab_backup.tar}} をリストア: # sudo -u gitlab -H rake RAILS_ENV=production gitlab:backup:restore BACKUP=/home/gitlab/gitlab/tmp/backups/20130125_11h35_1359131740 {{Note|バックアップフォルダは {{ic|config/gitlab.yml}} に設定されています。GitLab のバックアップとリストアについては [https://github.com/gitlabhq/gitlabhq/blob/master/doc/raketasks/backup_restore.md こちら] に記載があります。}} ===sqlite から mysql への移行=== 最新のコードを取得してください。 データを保存: # cd /home/gitlab/gitlab # sudo -u gitlab bundle exec rake db:data:dump RAILS_ENV=production [[#Mysql]] の手順に従ってデータベースをセットアップ: # sudo -u gitlab bundle exec rake db:setup RAILS_ENV=production 最後にデータをリストア: # sudo -u gitlab bundle exec rake db:data:load RAILS_ENV=production ===rvm で GitLab を実行=== rvm で gitlab を実行するにはまず rvm をセットアップしてください: curl -L https://get.rvm.io | bash -s stable --ruby=1.9.3 {{Note|互換問題を避けるためにバージョン 1.9.3 を使用することが現在推奨されています。}} For the complete installation you will want to be the final user (e.g. {{ic|git}}) so make sure to switch to this user and activate your rvm: su - git source "$HOME/.rvm/scripts/rvm" Then continue with the installation instructions from above. However, the systemd scripts will not work this way, because the environment for the rvm is not activated. The recommendation here is to create to separate shell scripts for {{ic|unicorn}} and {{ic|sidekiq}} to activate the environment and then start the service: {{hc|gitlab.sh|<nowiki> #!/bin/sh source `/home/git/.rvm/bin/rvm 1.9.3 do rvm env --path` bundle exec "unicorn_rails -c /usr/share/webapps/gitlab/config/unicorn.rb -E production"</nowiki> }} {{hc|sidekiq.sh|<nowiki> #!/bin/sh source `/home/git/.rvm/bin/rvm 1.9.3 do rvm env --path` case $1 in start) bundle exec rake sidekiq:start RAILS_ENV=production ;; stop) bundle exec rake sidekiq:stop RAILS_ENV=production ;; *) echo "Usage $0 {start|stop}" esac </nowiki>}} Then modify the above systemd files so they use these scripts. Modify the given lines: {{hc|gitlab.service|<nowiki> ExecStart=/home/git/bin/gitlab.sh </nowiki>}} {{hc|sidekiq.service|<nowiki> ExecStart=/home/git/bin/sidekiq.sh start ExecStop=/home/git/bin/sidekiq.sh stop </nowiki>}} ===SMTP を使って Gitlab からメールを送信=== gitlab サーバーから gmail (あるいは他のメールサービス) を使ってメールを送信することができます。これにより、gitlab サーバーにメールデーモンをインストールする手間が省けます。 メールサーバーの設定にあわせて {{ic|smtp_settings.rb}} を修正してください: {{hc|/usr/share/webapps/gitlab/config/initializers/smtp_settings.rb|<nowiki> if Rails.env.production? Gitlab::Application.config.action_mailer.delivery_method = :smtp Gitlab::Application.config.action_mailer.smtp_settings = { address: 'smtp.gmail.com', port: 587, domain: 'gmail.com', user_name: 'username@gmail.com', password: 'application password', authentication: 'plain', enable_starttls_auto: true } end</nowiki>}} Gmail will reject mails received this way (and send you a mail that it did). You will need to disable secure authentication (follow the link in the rejection mail) to work around this. The more secure approach is to enable two-factor authentication for username@gmail.com and to set up an application password for this configuration file. ==トラブルシューティング== ときどき GitLab が上手く動作しないことがあります。[https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide Trouble Shooting Guide] を確認してください。 === HTTPS が緑じゃない (gravatar が https を使わない) === Redis は gravatar の画像をキャッシュするため、http で GitLab にアクセスした後に https を有効にすると、gravatar がセキュアでない画像をロードしてしまいます。gitlab ユーザーで以下を実行することでキャッシュの消去が可能です: cd /usr/share/webapps/gitlab RAILS_ENV=production bundle exec rake cache:clear === push 時に bad line length character: API というエラーが発生する === push しようとすると以下のエラーが表示される場合: fatal: protocol error: bad line length character: API {{ic|/etc/webapps/gitlab-shell/secret}} と {{ic|/usr/share/webapps/gitlab/.gitlab_shell_secret}} が一致していることを確認してください。 一致していない場合、以下のコマンドでファイルを再作成してください: # ln -s /etc/webapps/gitlab-shell/secret /usr/share/webapps/gitlab/.gitlab_shell_secret === アップデート後のエラー === AUR からパッケージを更新したとき、データベースの移行やアセットのアップデートに失敗することがあります。再起動で問題が解決しない場合、以下の方法を試してみてください。 まず、gitlab のインストールディレクトリに移動: # cd /usr/share/webapps/gitlab 全ての gitlab ページが500エラーを返す場合、データベースの移行やアセットが古くなっている可能性があります。そうでない場合、以下のコマンドはスキップしてください。 # sudo -u gitlab -H bundle exec rake db:migrate RAILS_ENV=production gitlab のデプロイが永遠に完了しない場合、アセットが再コンパイルされていない可能性があります: # sudo -u gitlab -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production 最後に、gitlab サービスを再起動してサイトをテストしてください: # systemctl restart gitlab-unicorn gitlab-sidekiq gitlab-workhorse === /etc/webapps/gitlab/secret が空 === 通常は {{Pkg|gitlab-shell}} と {{Pkg|gitlab}} パッケージのインストール時に生成されますが、生成されなかった場合、手動で生成する必要があります: # hexdump -v -n 64 -e '1/1 "%02x"' /dev/urandom > /etc/webapps/gitlab-shell/secret # chown root:gitlab /etc/webapps/gitlab-shell/secret # chmod 640 /etc/webapps/gitlab-shell/secret # hexdump -v -n 64 -e '1/1 "%02x"' /dev/urandom > /etc/webapps/gitlab/secret # chown root:gitlab /etc/webapps/gitlab/secret # chmod 640 /etc/webapps/gitlab/secret ==参照== *[https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md 公式ドキュメント] *[https://gitlab.com/gitlab-org/gitlab-recipes Gitlab recipes with further documentation on running it with several webservers] *[https://github.com/gitlabhq/gitlabhq GitLab ソースコード]
このページで使用されているテンプレート:
テンプレート:Bc
(
ソースを閲覧
)
テンプレート:Hc
(
ソースを閲覧
)
テンプレート:Ic
(
ソースを閲覧
)
テンプレート:META Related articles start
(
ソースを閲覧
)
テンプレート:Note
(
ソースを閲覧
)
テンプレート:Pkg
(
ソースを閲覧
)
テンプレート:Related
(
ソースを閲覧
)
テンプレート:Related articles end
(
ソースを閲覧
)
テンプレート:Related articles start
(
ソースを閲覧
)
テンプレート:Tip
(
ソースを閲覧
)
GitLab
に戻る。
検索
検索
GitLabのソースを表示
話題を追加