1.安装subversion
在终端输入命令:
sudo apt-get install subversion
成功的话,终端应该会打印如下信息。
注意:在安装过程中,需要输入一次确认操作,输入Y 即可。
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-image-4.4.0-87-generic
linux-image-extra-4.4.0-87-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libapr1 libaprutil1 libserf-1-1 libsvn1
Suggested packages:
db5.3-util subversion-tools
The following NEW packages will be installed:
libapr1 libaprutil1 libserf-1-1 libsvn1 subversion
0 upgraded, 5 newly installed, 0 to remove and 104 not upgraded.
Need to get 1,687 kB of archives.
After this operation, 6,653 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://sg.mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libapr1 amd64 1.5.2-3 [86.0 kB]
Get:2 http://sg.mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libaprutil1 amd64 1.5.4-1build1 [77.1 kB]
Get:3 http://sg.mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libserf-1-1 amd64 1.3.8-1 [45.5 kB]
Get:4 http://sg.mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 libsvn1 amd64 1.9.3-2ubuntu1.1 [1,170 kB]
Get:5 http://sg.mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 subversion amd64 1.9.3-2ubuntu1.1 [308 kB]
Fetched 1,687 kB in 0s (3,575 kB/s)
Selecting previously unselected package libapr1:amd64.
(Reading database ... 132834 files and directories currently installed.)
Preparing to unpack .../libapr1_1.5.2-3_amd64.deb ...
Unpacking libapr1:amd64 (1.5.2-3) ...
Selecting previously unselected package libaprutil1:amd64.
Preparing to unpack .../libaprutil1_1.5.4-1build1_amd64.deb ...
Unpacking libaprutil1:amd64 (1.5.4-1build1) ...
Selecting previously unselected package libserf-1-1:amd64.
Preparing to unpack .../libserf-1-1_1.3.8-1_amd64.deb ...
Unpacking libserf-1-1:amd64 (1.3.8-1) ...
Selecting previously unselected package libsvn1:amd64.
Preparing to unpack .../libsvn1_1.9.3-2ubuntu1.1_amd64.deb ...
Unpacking libsvn1:amd64 (1.9.3-2ubuntu1.1) ...
Selecting previously unselected package subversion.
Preparing to unpack .../subversion_1.9.3-2ubuntu1.1_amd64.deb ...
Unpacking subversion (1.9.3-2ubuntu1.1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libapr1:amd64 (1.5.2-3) ...
Setting up libaprutil1:amd64 (1.5.4-1build1) ...
Setting up libserf-1-1:amd64 (1.3.8-1) ...
Setting up libsvn1:amd64 (1.9.3-2ubuntu1.1) ...
Setting up subversion (1.9.3-2ubuntu1.1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
如果终端打印出以下信息,即为安装遇到错误。
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package subversion
在安装软件时,遇到错误信息提示 : Unable to locate package subversion,即终端打印了上图信息。解决方法非常简单,在终端输入以下命令即可:
sudo apt-get update
2.创建资源仓库目录(注:如果资源仓库目录已存在,请忽略本步操作)
这里我选择使用的地址为:/home/dev/svn/repository,在终端输入以下命令:
mkdir -p /home/dev/svn/repository
mkdir (选项)(参数) -Z:设置安全上下文,当使用SELinux时有效; -m<目标属性>或--mode<目标属性>建立目录的同时设置目录的权限; -p或--parents 若所要建立目录的上层目录目前尚未建立,则会一并建立上层目录; --version 显示版本信息。
3.建立资源仓库
在终端输入以下命令(/home/dev/svn/repository即为你的资源仓库目录):
svnadmin create /home/dev/svn/repository
4.配置你的SVN服务器
(1)查看你的资源仓库目录是否设置成功,在终端输入 ls 命令:
ls /home/dev/svn/repository/
如果该目录下存在以下文件与目录,则表示仓库目录设置成功,否则请检查第 3 步。
conf db format hooks locks README.txt
(2)进入/home/svn/project/config目录,修改svnserve.conf
cd /home/dev/svn/repository/conf/
vim 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
### directory containing this file. The specified path may be a
### repository relative URL (^/) or an absolute file:// URL to a text
### file in a Subversion repository. 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
### The groups-db option controls the location of the groups file.
### Unless you specify a path starting with a /, the file's location is
### relative to the directory containing this file. The specified path
### may be a repository relative URL (^/) or an absolute file:// URL to a
### text file in a Subversion repository.
# groups-db = groups
### 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
### The hooks-env options specifies a path to the hook script environment
### configuration file. This option overrides the per-repository default
### and can be used to configure the hook script environment for multiple
### repositories in a single file, if an absolute path is specified.
### Unless you specify an absolute path, the file's location is relative
### to the directory containing this file.
# hooks-env = hooks-env
[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
对以上的信息进行如下修改:
注意:1.可以选择把如下信息直接粘贴到svnserve.conf;2.也可以找到对应的字段把其前面的 # 去除掉,但是需要注意的是去掉前面的#,并且顶格,不然可能会报错。
#匿名用户不可读(可改成read,即可读,但不推荐设置,看个人需要)
anon-access = none
#权限用户可写
auth-access = write
#密码文件为passwd
password-db = passwd
#权限文件为authz (似乎设置此项会出现问题,刚开始设置的时候使用有问题,反复的检查修改,最后发现取消此设置就#可以使用了,没明白原因。。。个人不推荐设置。。。)
authz-db = authz
(3)进入/home/svn/project/config目录,修改passwd
cd /home/dev/svn/repository/conf/
vim passwd
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
~
~
~
~
~
对以上的信息进行如下修改:
注意:前面是用户名,后面是密码,自己个性化设置。
admin = admin
(4)进入/home/svn/project/config目录,修改authz
cd /home/dev/svn/repository/conf/
vim 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
对以上的信息进行如下修改:
#用户admin(第二个)属于admin(第一个)权限组,前面为权限组,后面为用户名,例如:admin = root,多个用户时,以“,”逗号分割。
admin = admin
dev = admin
#admin权限组的权限是读和写
@admin = rw
#dev权限组的权限是读和写
[/dev]
@dev = rw
# 所有的组都具有读权限(此选项未进行设置,自己选择进不进行设置吧,个人觉得没什么必要 - -)
* = r
5.测试SVN服务器
(1)启动服务器
svnserve -d -r /home/dev/sv
-d:表示在后台运行
-r:指定服务器的根目录
使用如下命令查看svnserve是否已经运行:
ps aux | grep svnserve
root 16109 0.0 0.1 73488 940 ? Ss 20:36 0:00 svnserve -d -r /home/dev/svn
root 16113 0.0 0.1 14224 904 pts/0 S+ 20:37 0:00 grep --color=auto svnserve
此时,SVN服务器已在后台运行。
(2)停止服务器
killall svnserve
附:
SVN关闭命令:sudo killall svnserver
SVN启动命令:svnserver -d -r /home/svn/project
apache重启命令:sudo /etc/init.d/apache2 restart如果杀不死svnserver,
ps -ef|grep svnserve
找到PID,sudo kill -9 进程号
这样就杀死了
6.使用TortoiseSVN 在本地连接测试
测试成功~