Centos下安装git的web服务器


直接上代码

[Shell] 纯文本查看 复制代码
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#安装必备环境
yum install httpd git git-core -y #如果有端口修改 则  vi /etc/httpd/conf/httpd.conf 本处我修改成 8888端口. 80被nginx占用作为web使用. 故配apache作为git
 
chkconfig --levels 235 httpd on
 
service httpd restart
#此时访问8888则可以看到apache的身影了.  netstat -an | grep 8888 查看端口已开启
#接下来,创建git库目录  上面的环境已经创建了user apache用户. 这是背影
 
 
#创建目录并赋值权限
mkdir /data/git/test1 .git -p;
cd /data/git/test1 .git;
#初始化版本库
git init --bare; #所有者是apache的 
chown apache:apache /data/git -R;
 
 
#关联apache与git
echo "
#下面这行里有端口.注意
<VirtualHost *:8888>
#域名
         ServerName git. op .cn331.com
         SetEnv GIT_HTTP_EXPORT_ALL
#git项目的根目录
         SetEnv GIT_PROJECT_ROOT /data/git
         ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
         <Location />
                 AuthType Basic
                 AuthName "Git"
#用户密码文件,一会还要生成,这里写上即可
                 AuthUserFile /data/git/user #data.db
                 Require valid-user
         < /Location >
< /VirtualHost >"   > /etc/httpd/conf .d /apache_git .conf
 
#接下来生成密码文件  注意需要手动输入密码 下面是生成的test1 密码也写test1
htpasswd -m -c /data/git/user #data.db test1




重启apache

[Shell] 纯文本查看 复制代码
?
1
service httpd restart


最后测试 客户端

[Shell] 纯文本查看 复制代码
?
1
2
3
##git clone http://用户:密码@ip:端口/git/test1.git 比如
git clone http: //test1 :test1@127.0.0.1:8888 /git/test1 .git
cd test1/ ; echo "init" >readme.txt;git add . ; git commit -am 'init' ;git push origin master;


出现以下内容说明成功

* [new branch]      master -> master

转载于:https://www.cnblogs.com/ghjbk/p/6757743.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值