搭建CentOS上的Git服务器(Apache)
安装所需的软件包
# yum install -y httpd git
创建httpd配置文件
# cd /etc/httpd/conf.d/
# vi git.conf
git.conf 可以重写为 “git配置文件”。
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
-
- https://milestone-of-se.nesuke.com/sv-advanced/selinux/chcon-restorecon-semanage-fcontext/
- https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/6/html/managing_confined_services/sect-managing_confined_services-the_apache_http_server-types
服务设置
# 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
请参考这个页面
-
- http://www.torutk.com/projects/swe/wiki/CentOS_7%E3%81%A7apache%E7%B5%8C%E7%94%B1%E3%81%AEgit%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC%E3%82%92%E6%A7%8B%E7%AF%89
-
- http://d.hatena.ne.jp/ono51/20120619/p1
-
- https://httpd.apache.org/docs/2.4/ja/mod/quickreference.html
- https://git-scm.com/docs/git-http-backend