CentOS 安装 svn server

发布时间 2023-06-01 17:05:45作者: zno2

https://www.howtoforge.com/tutorial/how-to-setup-a-svn-server-on-centos-6/

安装

安装 subversion 只需一条命令

yum install -y subversion

输入的日志信息:

Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
epel                                                                                                                                                       | 4.3 kB  00:00:00     
extras                                                                                                                                                     | 3.4 kB  00:00:00     
os                                                                                                                                                         | 3.6 kB  00:00:00     
updates                                                                                                                                                    | 3.4 kB  00:00:00     
(1/5): epel/7/x86_64/group_gz                                                                                                                              | 170 kB  00:00:00     
(2/5): epel/7/x86_64/updateinfo                                                                                                                            | 679 kB  00:00:00     
(3/5): epel/7/x86_64/primary_db                                                                                                                            | 4.4 MB  00:00:00     
(4/5): extras/7/x86_64/primary_db                                                                                                                          | 166 kB  00:00:00     
(5/5): updates/7/x86_64/primary_db                                                                                                                         | 9.1 MB  00:00:00     
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package subversion.x86_64 0:1.7.14-10.el7 will be installed
--> Processing Dependency: subversion-libs(x86-64) = 1.7.14-10.el7 for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_wc-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_subr-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_repos-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_ra_svn-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_ra_neon-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_ra_local-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_ra-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_fs_util-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_fs_fs-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_fs_base-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_fs-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_diff-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_delta-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libsvn_client-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libneon.so.27()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: subversion-1.7.14-10.el7.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package neon.x86_64 0:0.30.0-3.el7 will be installed
--> Processing Dependency: libpakchois.so.0()(64bit) for package: neon-0.30.0-3.el7.x86_64
---> Package subversion-libs.x86_64 0:1.7.14-10.el7 will be installed
--> Running transaction check
---> Package pakchois.x86_64 0:0.4-10.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================
 Package                                         Arch                                   Version                                          Repository                          Size
==================================================================================================================================================================================
Installing:
 subversion                                      x86_64                                 1.7.14-10.el7                                    os                                 1.0 M
Installing for dependencies:
 apr                                             x86_64                                 1.4.8-3.el7                                      os                                 103 k
 apr-util                                        x86_64                                 1.5.2-6.el7                                      os                                  92 k
 neon                                            x86_64                                 0.30.0-3.el7                                     os                                 165 k
 pakchois                                        x86_64                                 0.4-10.el7                                       os                                  14 k
 subversion-libs                                 x86_64                                 1.7.14-10.el7                                    os                                 921 k

Transaction Summary
==================================================================================================================================================================================
Install  1 Package (+5 Dependent packages)

Total download size: 2.3 M
Installed size: 8.1 M
Downloading packages:
(1/6): apr-1.4.8-3.el7.x86_64.rpm                                                                                                                          | 103 kB  00:00:00     
(2/6): apr-util-1.5.2-6.el7.x86_64.rpm                                                                                                                     |  92 kB  00:00:00     
(3/6): neon-0.30.0-3.el7.x86_64.rpm                                                                                                                        | 165 kB  00:00:00     
(4/6): pakchois-0.4-10.el7.x86_64.rpm                                                                                                                      |  14 kB  00:00:00     
(5/6): subversion-1.7.14-10.el7.x86_64.rpm                                                                                                                 | 1.0 MB  00:00:00     
(6/6): subversion-libs-1.7.14-10.el7.x86_64.rpm                                                                                                            | 921 kB  00:00:00     
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                             2.7 MB/s | 2.3 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7.x86_64                                                                                                                                         1/6 
  Installing : apr-util-1.5.2-6.el7.x86_64                                                                                                                                    2/6 
  Installing : pakchois-0.4-10.el7.x86_64                                                                                                                                     3/6 
  Installing : neon-0.30.0-3.el7.x86_64                                                                                                                                       4/6 
  Installing : subversion-libs-1.7.14-10.el7.x86_64                                                                                                                           5/6 
  Installing : subversion-1.7.14-10.el7.x86_64                                                                                                                                6/6 
  Verifying  : neon-0.30.0-3.el7.x86_64                                                                                                                                       1/6 
  Verifying  : apr-1.4.8-3.el7.x86_64                                                                                                                                         2/6 
  Verifying  : subversion-1.7.14-10.el7.x86_64                                                                                                                                3/6 
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                                                                                                                    4/6 
  Verifying  : pakchois-0.4-10.el7.x86_64                                                                                                                                     5/6 
  Verifying  : subversion-libs-1.7.14-10.el7.x86_64                                                                                                                           6/6 

Installed:
  subversion.x86_64 0:1.7.14-10.el7                                                                                                                                               

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7      apr-util.x86_64 0:1.5.2-6.el7      neon.x86_64 0:0.30.0-3.el7      pakchois.x86_64 0:0.4-10.el7      subversion-libs.x86_64 0:1.7.14-10.el7     

Complete!

 

安装 mod_dav_svn  服务

yum install -y mod_dav_svn

输出的日志信息:

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mod_dav_svn.x86_64 0:1.7.14-10.el7 will be installed
--> Processing Dependency: httpd-mmn = 20120211x8664 for package: mod_dav_svn-1.7.14-10.el7.x86_64
--> Processing Dependency: httpd >= 2.4.6-37 for package: mod_dav_svn-1.7.14-10.el7.x86_64
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-40.el7.centos.4 for package: httpd-2.4.6-40.el7.centos.4.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-40.el7.centos.4.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================
 Package                                   Arch                                 Version                                               Repository                             Size
==================================================================================================================================================================================
Installing:
 mod_dav_svn                               x86_64                               1.7.14-10.el7                                         os                                    102 k
Installing for dependencies:
 httpd                                     x86_64                               2.4.6-40.el7.centos.4                                 updates                               2.7 M
 httpd-tools                               x86_64                               2.4.6-40.el7.centos.4                                 updates                                83 k
 mailcap                                   noarch                               2.1.41-2.el7                                          os                                     31 k

Transaction Summary
==================================================================================================================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 2.9 M
Installed size: 9.8 M
Downloading packages:
(1/4): httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm                                                                                                        |  83 kB  00:00:00     
(2/4): httpd-2.4.6-40.el7.centos.4.x86_64.rpm                                                                                                              | 2.7 MB  00:00:00     
(3/4): mailcap-2.1.41-2.el7.noarch.rpm                                                                                                                     |  31 kB  00:00:00     
(4/4): mod_dav_svn-1.7.14-10.el7.x86_64.rpm                                                                                                                | 102 kB  00:00:00     
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                             7.3 MB/s | 2.9 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mailcap-2.1.41-2.el7.noarch                                                                                                                                    1/4 
  Installing : httpd-tools-2.4.6-40.el7.centos.4.x86_64                                                                                                                       2/4 
  Installing : httpd-2.4.6-40.el7.centos.4.x86_64                                                                                                                             3/4 
  Installing : mod_dav_svn-1.7.14-10.el7.x86_64                                                                                                                               4/4 
  Verifying  : httpd-tools-2.4.6-40.el7.centos.4.x86_64                                                                                                                       1/4 
  Verifying  : mailcap-2.1.41-2.el7.noarch                                                                                                                                    2/4 
  Verifying  : httpd-2.4.6-40.el7.centos.4.x86_64                                                                                                                             3/4 
  Verifying  : mod_dav_svn-1.7.14-10.el7.x86_64                                                                                                                               4/4 

Installed:
  mod_dav_svn.x86_64 0:1.7.14-10.el7                                                                                                                                              

Dependency Installed:
  httpd.x86_64 0:2.4.6-40.el7.centos.4                       httpd-tools.x86_64 0:2.4.6-40.el7.centos.4                       mailcap.noarch 0:2.1.41-2.el7                      

Complete!

 

配置

Great, now the installation part is done. Next, we'll move forward on the configuration part. First, let's create a dedicated directory for SVN repository usage. This is an optional process but it's a good practice when implementing for a larger scale group. Below are the steps:

mkdir /data/svn
Usage: mkdir [OPTION]... DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.

Mandatory arguments to long options are mandatory for short options too.
  -m, --mode=MODE   set file mode (as in chmod), not a=rwx - umask
  -p, --parents     no error if existing, make parent directories as needed
  -v, --verbose     print a message for each created directory
  -Z, --context[=CTX]  set the SELinux security context of each created
                         directory to default type or to CTX if specified
      --help     display this help and exit
      --version  output version information and exit

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report mkdir translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'mkdir invocation'
mkdir 命令帮助

Now we will create our first repository directory, I will name it repo1. As a client shall be able to access the repository via browser or SVN client tools later, we will grant the ownership for the directory to apache as it is the owner of the web server service. Below are the steps:

svnadmin create /data/svn/repo1
chown -R apache:apache /data/svn/repo1
Name
svnadmin create — Create a new, empty repository.

Synopsis
svnadmin create REPOS_PATH

Description
Create a new, empty repository at the path provided. If the provided directory does not exist, it will be created for you.[82] As of Subversion 1.2, svnadmin creates new repositories with the FSFS filesystem backend by default.

While svnadmin create will create the base directory for a new repository, it will not create intermediate directories. For example, if you have an empty directory named /var/svn, creating /var/svn/repos will work, while attempting to create /var/svn/subdirectory/repos will fail with an error. Also, keep in mind that, depending on where on your system you are creating your repository, you might need to run svnadmin create as a user with elevated privileges (such as the root user).
svnadmin 命令帮助
Usage: chown [OPTION]... [OWNER][:[GROUP]] FILE...
  or:  chown [OPTION]... --reference=RFILE FILE...
Change the owner and/or group of each FILE to OWNER and/or GROUP.
With --reference, change the owner and group of each FILE to those of RFILE.

  -c, --changes          like verbose but report only when a change is made
  -f, --silent, --quiet  suppress most error messages
  -v, --verbose          output a diagnostic for every file processed
      --dereference      affect the referent of each symbolic link (this is
                         the default), rather than the symbolic link itself
  -h, --no-dereference   affect symbolic links instead of any referenced file
                         (useful only on systems that can change the
                         ownership of a symlink)
      --from=CURRENT_OWNER:CURRENT_GROUP
                         change the owner and/or group of each file only if
                         its current owner and/or group match those specified
                         here.  Either may be omitted, in which case a match
                         is not required for the omitted attribute
      --no-preserve-root  do not treat '/' specially (the default)
      --preserve-root    fail to operate recursively on '/'
      --reference=RFILE  use RFILE's owner and group rather than
                         specifying OWNER:GROUP values
  -R, --recursive        operate on files and directories recursively

The following options modify how a hierarchy is traversed when the -R
option is also specified.  If more than one is specified, only the final
one takes effect.

  -H                     if a command line argument is a symbolic link
                         to a directory, traverse it
  -L                     traverse every symbolic link to a directory
                         encountered
  -P                     do not traverse any symbolic links (default)

      --help     display this help and exit
      --version  output version information and exit

Owner is unchanged if missing.  Group is unchanged if missing, but changed
to login group if implied by a ':' following a symbolic OWNER.
OWNER and GROUP may be numeric as well as symbolic.

Examples:
  chown root /u        Change the owner of /u to "root".
  chown root:staff /u  Likewise, but also change its group to "staff".
  chown -hR root /u    Change the owner of /u and subfiles to "root".

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report chown translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'chown invocation'
chown 命令帮助

 

Once done, you'll notice that several related folder and files will be created by default under our new repository directory.

cd /data/svn/repo1
ls

显示的信息:

README.txt  conf  db  format  hooks  locks

Now we edit the configuration file to meet our requirements. First, we will edit the configuration file svnserver.conf to accept the related privileges that we'll assign on the granted user. Below are the steps:

cd conf/
ls

显示的信息:

authz  passwd  svnserve.conf

 

vi svnserve.conf

显示的信息:

### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository.  (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)

### Visit http://subversion.apache.org/ for more information.

[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
# anon-access = read
# auth-access = write
### The password-db option controls the location of the password
### database file.  Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
# password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control.  Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file.  If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
# authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa.  The default realm
### is repository's uuid.
# realm = My First Repository
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above.  Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
# force-username-case = none

[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### This section will be ignored if svnserve is not built with Cyrus
### SASL support; to check, run 'svnserve --version' and look for a line
### reading 'Cyrus SASL authentication is available.'
# use-sasl = true
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
### integrity-checking only, values larger than 1 are correlated
### to the effective key length for encryption (e.g. 128 means 128-bit
### encryption). The values below are the defaults.
# min-encryption = 0
# max-encryption = 256

放开这些注释,保存退出

[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz

Then create a new file named passwd that will contain a list of users for the SVN repository. Below are the steps:

htpasswd -c /data/svn/repo1/conf/passwd jay
Usage:
	htpasswd [-cimBdpsDv] [-C cost] passwordfile username
	htpasswd -b[cmBdpsDv] [-C cost] passwordfile username password

	htpasswd -n[imBdps] [-C cost] username
	htpasswd -nb[mBdps] [-C cost] username password
 -c  Create a new file.
 -n  Don't update file; display results on stdout.
 -b  Use the password from the command line rather than prompting for it.
 -i  Read password from stdin without verification (for script usage).
 -m  Force MD5 encryption of the password (default).
 -B  Force bcrypt encryption of the password (very secure).
 -C  Set the computing time used for the bcrypt algorithm
     (higher is more secure but slower, default: 5, valid: 4 to 31).
 -d  Force CRYPT encryption of the password (8 chars max, insecure).
 -s  Force SHA encryption of the password (insecure).
 -p  Do not encrypt the password (plaintext, insecure).
 -D  Delete the specified user.
 -v  Verify password for the specified user.
On other systems than Windows and NetWare the '-p' flag will probably not work.
The SHA algorithm does not use a salt and is less secure than the MD5 algorithm.
htpasswd 命令帮助

 

输入密码,确认密码,显示文件内容,信息如下:

[root@VM_7_88_centos conf]# htpasswd -c /data/svn/repo1/conf/passwd jay
New password: 
Re-type new password: 
Adding password for user jay
[root@VM_7_88_centos conf]# cat passwd
jay:$apr1$b6.oLsYi$Z4WB99ImPy3Jo.wI6N6aN/

Done, we have successfully created a user for the SVN repository use. Let's create 2 more users to access SVN repository. Below are the steps:

htpasswd /data/svn/repo1/conf/passwd fikri
htpasswd /data/svn/repo1/conf/passwd farid

Done, now there are 3 users listed for SVN repository use. For this practice, I would like to show how we can limit the privileges of a user. Let's assign the privilege to access the repo1 repository. To do this, we need to edit the authz configuration file. Below are the steps:

vi authz

显示的信息:

### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
~                                                                                                                                                                                 
~                                                                                                                                                                                 
~                                                                                                                                                                                 
"authz" 32L, 1080C

编辑文本,设置三个用户的权限,保存退出。

[repo1:/]
farid = r
fikri = rw
* =

Based on the configuration above, we've set different privileges for the 3 users that we created earlier. We assigned user FARID to have READ ONLY privileges, FIKRI to have READ WRITE privileges and JAY or others to not having any privileges. Means that later in testing I'll show you that user JAY will not be able to view any files in the repo1 repository.

Now let's edit the HTTPD service configuration file.

vi /etc/httpd/conf/httpd.conf

显示的信息:

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin root@localhost

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"

#
# Relax access to content within /var/www.
#
<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
    Require all denied
</Files>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error_log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    #CustomLog "logs/access_log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to
    # exist in your server's namespace, but do not anymore. The client
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig /etc/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default.  To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    #
    # The mod_mime_magic module allows the server to use various hints from the
    # contents of the file itself to determine its type.  The MIMEMagicFile
    # directive tells the module where the hint definitions are located.
    #
    MIMEMagicFile conf/magic
</IfModule>

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall may be used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults if commented: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile on

# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf

编辑内容,保存退出。(已经有了一个IncludeOptional 就不设置下面这个了)

[.....]
Include conf.d/*.conf
[.....]

Next we go to the conf.d directory to do some changes in the related configuration files. You'll notice that there is a file subversion.conf already. Edit the file in order to make the repository available to be viewed in the browserBelow are the steps :-

cd /etc/httpd/conf.d/
ls

显示的内容(并没有subversion.conf ,那我就新建一个):

README  autoindex.conf  userdir.conf  welcome.conf
vi subversion.conf

添加下面内容:

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

<Location /repo1>
DAV svn
SVNPath /data/svn/repo1
Authtype Basic
AuthName "My Repository"
AuthzSVNAccessFile /data/svn/repo1/conf/authz
AuthUserFile /data/svn/repo1/conf/passwd
Require valid-user
</Location>

The first two lines load the apache SVN module, the next lines define that the URL /repo1 points to our created repository.

We also set that specific users have read/write privileges on specific items within the repository using AuthzSVNAccessFile. The list of users will be taken from the /data/svn/repo1/conf/passwd file.

Now restart the HTTPD server in order to load the configuration changes made.

service httpd restart
Usage: service < option > | --status-all | [ service_name [ command | --full-restart ] ]
service 命令帮助

 

显示内容:

Redirecting to /bin/systemctl restart  httpd.service

测试

登陆之后成功页面