使用apache搭建git服务器
服务端搭建
创建git仓库
mkdir -p && cd /var/www/git
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/git(/.*)?"
restorecon -R /var/www/html/git/
chown -R apache:apache /var/www/html/git/
创建一个测试用的git仓库
git init --bare example.git
配置apache服务器
file:/etc/httpd/conf.d/git.conf
启用git
SetEnv GIT_PROJECT_ROOT /var/www/git/
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ "/usr/libexec/git-core/git-http-backend/"
设置用户验证
AuthType Basic
AuthName "GIT Repository"
AuthUserFile "/etc/httpd/.htpasswd"
Require valid-user
创建密码,然后重启服务
htpasswd -c /etc/httpd/.htpasswd master1
systemctl reload httpd
client验证
git remote add origin http://server1.somata.net/git/example.git
git pull origin
555
观点新颖,见解独到,发人深省。