GIT 服务配置

Registry 上做配置

在 Registry 上创建仓库

mkdir -p /opt/git/repo/cakephp.git
cd /opt/git/repo/cakephp.git
git init --bare
mv hooks/post-update.sample hooks/post-update

拷贝例子到 Registry

scp cakephp-ex-master.zip root@10.66.192.79:/opt

复制并提交第一份代码

cd /opt/
git clone file:///opt/git/repo/cakephp.git/
unzip cakephp-ex-master.zip
cp -rf cakephp-ex-master/* cakephp
cp -rf cakephp-ex-master/.sti cakephp
cp -rf cakephp-ex-master/.htaccess cakephp
cp -rf cakephp-ex-master/.gitignore cakephp
cd cakephp
git add --all
git commit -m "init commit"
git push origin master

发布仓库到 httpd

创建文件/etc/httpd/conf.d/git.conf

cat << EOF > /etc/httpd/conf.d/git.conf
Alias /git "/opt/git/repo"
<Directory "/opt/git/repo">
    AllowOverride None
  Dav On
    Options +Indexes +FollowSymLinks
Require all granted
</Directory>
<Directory "/opt/git/repo/cakephp.git/">
    Require all granted
</Directory>
<Location /git>
SetHandler None
</Location>
EOF

重启 httpd 使配置生效

systemctl restart httpd

配置 iptables 规则

cp /etc/sysconfig/iptables /etc/sysconfig/iptables.bak.$(date "+%Y%m%d%H%M%S")
sed -i '/.*--dport 22 -j ACCEPT.*/a\-A INPUT -p tcp -m state --state NEW -m tcp --dport 5000 -j ACCEPT' /etc/sysconfig/iptables
sed -i '/.*--dport 22 -j ACCEPT.*/a\-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT' /etc/sysconfig/iptables
systemctl restart iptables

测试 GIT 服务

在所有机器上测试 GIT 服务配置

cd /tmp
git clone http://git.example.com/git/cakephp.git

results matching ""

    No results matching ""