Linux git服务器http方式搭建
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
·
Git访问方式:基于http的基本验证(非SSL)
Apache的安装
1. 安装Apache软件:yum install httpd
2. 设置Apache在服务器启动时运行:chkconfig --levels 235 httpd on
Git的安装与配置
1. 安装git
2. 安装 git-core(为了使用git-http-backend——支持git的CGI程序,apache支持git就靠它)
3. 创建存放git repository的文件夹,比如这里是/gitServer
4. 创建一个空的项目
5. 修改上一步创建的文件夹gitServer的所有者与所属群组,要让apache能读/写这个文件夹
chown命令使用帮助: 每天一个linux命令(30): chown命令
Apache的配置
1. 创建用于git用户验证的帐户(用户帐户由apache管理)
1.1 创建新用户
然后输入该用户要使用的密码。
1.2 修改git-team.htpasswd文件的所有者与所属群组
1.3 设置git-team.htpasswd文件的访问权限
chmod命令使用帮助: 每天一个linux命令(27):linux chmod命令
2. 修改apache配置文件httpd.conf
2.1 用vim打开httpd.conf:vi /etc/httpd/conf/httpd.conf
2.2 将光标移至文件结尾:0G
2.3 添加如下的内容:
ServerName是git服务器的域名
/home/git是代码库存放的文件夹
ScriptAlias是将以/git/开头的访问路径映射至git的CGI程序git-http-backend
AuthUserFile是验证用户帐户的文件
2.4 保存并退出:x
3. 重启apache使设置生效
客户端访问Git服务器
运行以下命令签出git-test项目:
Apache的安装
1. 安装Apache软件:yum install httpd
2. 设置Apache在服务器启动时运行:chkconfig --levels 235 httpd on
Git的安装与配置
1. 安装git
yum install git
2. 安装 git-core(为了使用git-http-backend——支持git的CGI程序,apache支持git就靠它)
yum install git-core
3. 创建存放git repository的文件夹,比如这里是/gitServer
mkdir gitServer && cd gitServer
4. 创建一个空的项目
cd gitServergit init --bare sample.git
5. 修改上一步创建的文件夹gitServer的所有者与所属群组,要让apache能读/写这个文件夹
chown -R apache:apache .
chown命令使用帮助: 每天一个linux命令(30): chown命令
Apache的配置
1. 创建用于git用户验证的帐户(用户帐户由apache管理)
1.1 创建新用户
htpasswd -m -c /etc/httpd/conf.d/git-team.htpasswd <username>
示例 htpasswd -m -c /etc/httpd/conf.d/git-team.htpasswd zhangcheng
然后输入该用户要使用的密码。
1.2 修改git-team.htpasswd文件的所有者与所属群组
chown apache:apache /etc/httpd/conf.d/git-team.htpasswd
1.3 设置git-team.htpasswd文件的访问权限
chmod 640 /etc/httpd/conf.d/git-team.htpasswd
chmod命令使用帮助: 每天一个linux命令(27):linux chmod命令
2. 修改apache配置文件httpd.conf
2.1 用vim打开httpd.conf:vi /etc/httpd/conf/httpd.conf
2.2 将光标移至文件结尾:0G
2.3 添加如下的内容:
<VirtualHost *:80>
ServerName git.cnblogs.com
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv GIT_PROJECT_ROOT /gitServer
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
<Location />
AuthType Basic
AuthName "Git"
AuthUserFile /etc/httpd/conf.d/git-team.htpasswd
Require valid-user
</Location>
</VirtualHost>
ServerName是git服务器的域名
/home/git是代码库存放的文件夹
ScriptAlias是将以/git/开头的访问路径映射至git的CGI程序git-http-backend
AuthUserFile是验证用户帐户的文件
2.4 保存并退出:x
3. 重启apache使设置生效
service httpd restart
客户端访问Git服务器
运行以下命令签出git-test项目:
git clone http://<username>:<password>@git.cnblogs.com/git/sample.git[/code]
示例 http://zhangcheng:dancheng51@192.168.8.200/git/sample.git
如果访问不到注意80端口是否开启
重启防火墙 service iptables restart 输入用户名与密码,如果输出下面的信息,就说明签出成功。remote: Counting objects: 6, done. remote: Compressing objects: 100% (4/4), done. remote: Total 6 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (6/6), done.
htpasswd -m -c /etc/httpd/conf.d/git-team.htpasswd <username>
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 5 年前
5def40a3
Add host customization support for the NodeJS version 5 年前
新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。
更多推荐


所有评论(0)