1
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 3 years have passed since last update.

ubuntu20.04/debian10+apacheでgitサーバ(smart http)

Posted at

何か下書き一覧に「3 month ago」とか書かれていた(笑)
せっかく書いたのだから放置しておくのもなんですし、もう20.10も出る頃ですので、その前に公開しておきましょう。

前回(?)の続きです。

まぁ、自分が使うのは主にFreeBSDか、ubuntuかdebianなんで、この際ubuntu/debianでも試してみようかと。

環境

  • VirtualBox on ubuntu20.04
  • ubuntu server 20.04

前回と同様、インストールしてネットワークが接続てきているところまで設定し終わっている事を前提とします。

設定

sudo apt install apache2 git

なんかgitは最初から入っていたようなのだけど、気の所為かもしれないので念の為。

ubuntuの場合、「/etc/apache2/sites-available」ディレクトリ以下にホストの設定を書くのが流儀みたいなので、デフォルトの設定をコピーして設定します。

sudo cp -v /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-myhost.conf

コピーした後、編集。

<VirtualHost *:80>  

    # もともと書かれてあったものは、そのまま。

    SetEnv GIT_PROJECT_ROOT /var/www/git
    SetEnv GIT_HTTP_EXPORT_ALL
    ScriptAlias /git /usr/lib/git-core/git-http-backend
    <Location /git>  
        AuthName "Git Repository"
        AuthType Basic
        AuthUserFile /etc/apache2/git.passwd
        Require valid-user
    </Location>
</VirtualHost>

パスワードファイルを作成します。

sudo htpasswd -c /etc/apache2/git.passwd katsuko

CGIモジュールと、先のホスト設定ファイルを有効にします。
(デフォルト設定のホストファイルを無効にします)

sudo a2enmod cgi
sudo a2dissite 000-default
sudo a2ensite 000-myhost

レポジトリの作成。

sudo mkdir -p /var/www/git
sudo git init --bare --shared /var/www/git/project.git
cd /var/www/git/project.git
sudo git update-server-info 
sudo chown -R www-data:www-data .

サーバの再起動。

sudo systemctl restart apache2

Debian 10 (Buster)の場合

上と一緒。

いや手抜きじゃなくて。
まぁ、debianの場合rootで作業するので、その場合は「sudo」は要らない、という点ぐらいは察してください。

1
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
1
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?