Build a SVN server supporting HTTP in CentOS 7
Prerequisites:
Disable the firewall or selinux first. Of course, you can configure it to allow some ports to pass through
I am violent, and I use close to handle it.
systemctl disable firewalldsystemctl stop firewalld
Disable is to make it not start next time, stop is to end it.
For selinux
Change "selinux = enforcing" to "SELINUX = disabled" in the/etc/SELINUX/config file"
Then run "setenforce 0" to disable selinux without restarting.
1. Install the appropriate software
# Svn server yum install subversion # apache server, which enables our svn server to Support http access, not only svn: // protocol yum install httpd # apache svn module yum install mod_dav_svn
2. Configuration
1. Create a repository
The root repository (root repository) of the svn server installed by default is/var/svn, So we create our repository in this directory.
svnadmin create repo1
The/var/svn/repo1 directory will be created with the corresponding configuration file under the repo1 directory
2. repository Configuration
The three configuration files under/var/svn/repo1/conf serve
Svnserve. conf: authentication and authorization policies for storing svn servers: for example, anonymous readable, writable authenticated users, and the location of the user information storage location (passwd) and authentication rule file (authz)
Passwd: the user information storage file, which is stored as a username = password Key-value pair.
Authz: authentication rules
Note the spaces before and after the equal sign (=) of the key-Value Pair
For svnserve. conf, just remove the comments of the following lines.
anon-access = readauth-access = writepassword-db = passwdauthz-db = authz
For passwd, add a user
root = 123456
For authz, add the following information:
[repo1:/]root = rw* = r
It indicates that the root user has the read and write permissions, and '*' can be read by anyone. If this configuration is not available, an exception is reported when you view the log.
3. Test
Start the server:
systemctl start svnserve.service
Use tortoiseSVN, svn: // ip/repo1. If the access is normal, configure OK,
3. Http access configurationThe default configuration file of httpd is/etc/httpd/conf/httpd. conf.
1. Back up the data to prevent correction:
cp httpd.conf httpd.conf.bak
2. Modify
Find the 'loadmodule' of the file'
Load the configuration of the mod_dav and mod_dav_svn modules nearby:
LoadModule dav_module modules/mod_dav.soLoadModule dav_svn_module modules/mod_dav_svn.so
Add the following configuration at the end of the file:
<Location /svn>DAV svnSVNParentPath /var/svn# Authentication: BasicAuthName "Subversion repository"AuthType BasicAuthUserFile /etc/httpd/svn-auth.htpasswd# Authorization: Authenticated users only<LimitExcept GET PROPFIND OPTIONS REPORT>Require valid-user</LimitExcept></Location>
"/Svn" in "<Location/svn>" indicates that the svn access URL is "http: // ip/svn ",
"DAV svn" indicates that the "mod_dav_svn" module is used. dav is an http 1.1 extension protocol. mod_dav_svn is only an application of this Protocol.
"SVNParentPath/var/svn" indicates the service "http: // ip/svn" request, use the corresponding content under the "/var/svn" path.
AuthName indicates the prompt message when the user name and password are entered.
AuthType. Here we use the basic authentication type.
AuthUserFile indicates the location of the authentication file, which will be created later.
The limit10000t node indicates that user authentication is required only for write requests.
3. Create a svn-auth.htpasswd File
htpasswd -c -m /etc/httpd/svn-auth.htpasswd root
Enter the password twice as prompted, and we create a 'root ',
4. Grant the apache user the write permission on the "/var/svn/repo1" directory.
Httpd is started with an apache user, so we need to grant the write permission to "/var/svn/repo1. Because the owner of my environment "/var/svn/repo1" is "root: root", I add apache to the root group, let the root group also have the permission to solve the problem.
# Add User apache to the root group usermod-a-G root apache # grant the group permission to write chmod-R g + w/var/svn/ repo1 # view groups of apache users groups apache
5. Test
Systemctl start httpd. service
Now we can access our svn server through "http: // ip/repo1 ".
Tip:
The Error log File of httpd is/var/log/httpd/error_log. If any problem occurs, check the file for a prompt at any time.
References:Http://svnbook.red-bean.com/en/1.7/svn.serverconfig.httpd.html