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作为gitchkconfig --levels 235 httpd onservice 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与gitecho "#下面这行里有端口.注意<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 密码也写test1htpasswd -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
将来不迎,当下不杂,过往不念。

浙公网安备 33010602011771号