1. 创建仓库(在 Registry 上操作)
mkdir -p /opt/git/repo/cakephp.git;
cd /opt/git/repo/cakephp.git;
git init --bare;
git update-server-info;
mv hooks/post-update.sample hooks/post-update;
2. 拷贝 cakephp-ex-master.zip 到 Registry 上 (在 MAC 上操作)
scp cakephp-ex-master.zip root@192.168.56.112:/opt
3. 复制并提交第一份代码(在 Registry 上操作)
cd /opt;
git clone file:///opt/git/repo/cakephp.git/;
unzip cakephp-ex-master.zip;
cp cakephp-ex-master/* cakephp -rf;
cp cakephp-ex-master/.sti cakephp -rf;
cp cakephp-ex-master/.htaccess cakephp -rf;
cp cakephp-ex-master/.gitignore cakephp -rf;
cd cakephp;
git add .;
git commit -m 'initial upload';
git push origin master;
4. 发布仓库到 httpd(在 Registry 上操作)
创建文件/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
5. 重启 httpd 使配置生效(在 Registry 上操作)
systemctl restart httpd
6. 配置 iptables 规则(在 Registry 上操作)
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;
7. 测试 GIT 服务(在所有机器上操作)
cd /tmp;
git clone http://git.example.com/git/cakephp.git/;
rm -rf cakephp;
mkdir -p /opt/git/repo/cakephp.git;
cd /opt/git/repo/cakephp.git;
git init --bare;
git update-server-info;
mv hooks/post-update.sample hooks/post-update;
2. 拷贝 cakephp-ex-master.zip 到 Registry 上 (在 MAC 上操作)
scp cakephp-ex-master.zip root@192.168.56.112:/opt
3. 复制并提交第一份代码(在 Registry 上操作)
cd /opt;
git clone file:///opt/git/repo/cakephp.git/;
unzip cakephp-ex-master.zip;
cp cakephp-ex-master/* cakephp -rf;
cp cakephp-ex-master/.sti cakephp -rf;
cp cakephp-ex-master/.htaccess cakephp -rf;
cp cakephp-ex-master/.gitignore cakephp -rf;
cd cakephp;
git add .;
git commit -m 'initial upload';
git push origin master;
4. 发布仓库到 httpd(在 Registry 上操作)
创建文件/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
5. 重启 httpd 使配置生效(在 Registry 上操作)
systemctl restart httpd
6. 配置 iptables 规则(在 Registry 上操作)
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;
7. 测试 GIT 服务(在所有机器上操作)
cd /tmp;
git clone http://git.example.com/git/cakephp.git/;
rm -rf cakephp;
没有评论:
发表评论