LoginSignup
7
8

More than 5 years have passed since last update.

CentOSにGitサーバー(Apache)を構築

Last updated at Posted at 2019-03-03
必要なパッケージをインストール
# yum install -y httpd git
httpd設定ファイル作成
# cd /etc/httpd/conf.d/
# vi git.conf
git.conf
SetEnv GIT_PROJECT_ROOT /var/lib/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
<LocationMatch "^/git/">
  Require all granted
</LocationMatch>
ファイアウォールの設定
# firewall-cmd --permanent --add-service=http
# firewall-cmd --reload
Gitリポジトリ作成
# mkdir /var/lib/git
# cd /var/lib/git
# git init --bare --shared test.git
# cd test.git
# git update-server-info
# git config http.receivepack true
# mv hooks/post-update.sample hooks/post-update
# chown -R apache.apache /var/lib/git
SELinux設定
# semanage fcontext -a -t httpd_var_lib_t '/var/lib/git(/.*)?'
# semanage fcontext -a -t httpd_sys_script_exec_t '/var/lib/git/[^/]+/hooks(/.*)?'
# restorecon -v -R /var/lib/git

SELinuxについて

サービス設定
# systemctl enable httpd
# systemctl start httpd
アクセス
# git remote add origin http://git-server/git/test.git
# git push --set-upstream origin master
# git clone http://git-server/git/test.git
参考ページ
7
8
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
7
8