*Http Git Server

  1. Git server 支援 SSH 及 HTTP 兩種協定,本系統採用 http 協定存取 git repository,先安裝 httpd 套件。
    root@ip123:/srv/git# dnf install httpd
    
  2. vi 編輯 /etc/httpd/conf.d/git.conf,限制用戶存取 python_pg.git
    root@ip123:/srv/git# vi /etc/httpd/conf.d/git.conf 
    <VirtualHost *:80>
        ServerName deyu.wang
    
        # Set environment variables for git-http-backend
        SetEnv GIT_PROJECT_ROOT /srv/git
        SetEnv GIT_HTTP_EXPORT_ALL
        ScriptAliasMatch "(?x)^/(.*/(HEAD | \
            info/refs | \
            objects/(info/[^/]+ | \
            [0-9a-f]{2}/[0-9a-f]{38} | \
            pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
            git-(upload|receive)-pack))$" \
            "/usr/libexec/git-core/git-http-backend/$1"
    
        # Directory for the git-http-backend script
        <Directory "/usr/libexec/git-core">
            Options +ExecCGI
            Require all granted
        </Directory>
    
        <Location "^/python_pg.git">
            AuthType Basic
            AuthName "Git Access"
            AuthUserFile "/etc/httpd/conf.d/git.pyuser.htpasswd"
            Require valid-user
        </Location>
    </VirtualHost>
    
  3. 使用 htpasswd 建立可存取 python_pg.git 的用戶檔。
    root@ip123:/srv/git# htpasswd -c /etc/httpd/conf.d/git.pyuser.htpasswd pyuser
    New password:
    Re-type new password:
    Adding password for user pyuser
    
  4. 設定 httpd 開機啟動且現在啟動。
    root@ip123:/srv/git# systemctl enable --now httpd