Recently learning Linux, finally on Linux with Apache built a git server, this record.
Server: Aliyun Server
Linux version: CentOS 6.5
Apache version: apache/2.2.15
git version: Git 1.7.1
Git access mode: Basic authentication based on HTTP (non-SSL)
The installation of Apache
1. Install Apache software: Yum install httpd
2. Set Apache to run when Server starts: Chkconfig--levels 235 httpd on
Installation and configuration of Git
1. Install git
Yum Install git
2. Install Git-core (in order to use git-http-backend--to support git CGI program, Apache support git depends on it)
Yum Install Git-core
3. Create a folder that holds Git repository, for example, this is/home/git
Cd/home && mkdir git && cd git
4. Create an empty project
mkdir git-test && CD git-test
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/web/
5. Modify the folder created in the previous step the owner and the group of the Git-test, so that Apache can read/write this folder
chown command Use Help: one Linux command per day: chown command
Apache Configuration
1. Create an account for Git user authentication (user accounts are managed by Apache)
1.1 Creating a new user
Htpasswd-m-c/etc/httpd/conf.d/git-team.htpasswd <username>
Then enter the password that the user wants to use.
1.2 Modify the owner of the git-team.htpasswd file and the owning group
Chown apache:apache/etc/httpd/conf.d/git-team.htpasswd
1.3 Setting access rights for GIT-TEAM.HTPASSWD files
chmod 640/etc/httpd/conf.d/git-team.htpasswd
chmod command Use Help: one Linux command per day: Linux chmod command
2. Modify Apache configuration file httpd.conf
2.1 Open httpd.conf:vi/etc/httpd/conf/httpd.conf with VIM
2.2 Move the cursor to the end of the file: 0G
2.3 Add the following:
<virtualhost *:80>
ServerName git.cnblogs.com
setenv git_http_export_all setenv git_project_root
/home/git
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 is the domain name of the GIT server
/home/git is the folder where code inventory is placed
Scriptalias is the CGI program that maps the access path that begins with/git/to git git-http-backend
AuthUserFile is the file that validates the user account
2.4 Save and exit: X
3. Restart Apache to make settings effective
Service httpd Restart
Client Access git server
Run the following command to check out the Git-test project:
git clone http://git.cnblogs.com/git/git-test
Enter the username and password, and if the following information is exported, the checkout is successful.
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.