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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM