zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    实现一个基于tcc/tlink的简单的编译链接工具
    从函数指针数组的运用来看程序结构化设计(2)
    从函数指针数组的运用来看程序结构化设计
    crypt()函数
    PHP fopen()函数 打开文件
    PHP 数据库访问
    php中图像处理的常用函数
    PHP Cookie的用法
    Spring的依赖注入
    拦截器
  • 原文地址:https://www.cnblogs.com/ghjbk/p/6781675.html
Copyright © 2011-2022 走看看