ここではGitリポジトリの作成とWebサーバーで参照する方法を記載いたします。
事前作業
# root権限に昇格する
sudo -s
1.Gitリポジトリの作成
mkdir -p /var/lib/git/winkler.git
cd /var/lib/git/winkler.git
git --bare init
git update-server-info
chown -R www-data .
2.Apache2への公開設定ファイル「git.conf」を設定する
「/etc/apache2/conf-available」に移動して「git.conf」を作成する
# /etc/apache2/conf-available に移動する
cd etc/apache2/conf-available
# git.confファイルを新規作成
vi git.conf
-------------------------------------------------------------
# 新規作成
SetEnv GIT_PROJECT_ROOT /var/lib/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
<Location /git>
Options ExecCGI
AuthName "Git for HTTP"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Location>
------------------------------------------------------------
作成したgit.confファイルをApacheに適用する
# git.confファイルをApacheに適用
a2enconf git
#cgiをApacheに適用
a2enmod cgi rewrite
#Apacheの再起動
systemctl restart apache2
apacheユーザーを登録する
# ユーザーを登録:[-c]でファイルの新規作成
htpasswd -c /etc/apache2/.htpasswd admin
New password: # パスワード設定
Re-type new password:
Adding password for user admin