安装: yum -y install subversion
14:21:13 root@localhost ~ $yum -y install subversion Loaded plugins: fastestmirror, security Setting up Install Process Determining fastest mirrors * elrepo: mirrors.tuna.tsinghua.edu.cn base | 3.7 kB 00:00 base/primary_db | 4.7 MB 00:00 centos-sclo-rh | 2.9 kB 00:00 centos-sclo-rh/primary_db | 489 kB 00:42 centos-sclo-rh/primary_db | 1.2 MB 00:52 centos-sclo-sclo | 2.9 kB 00:00 centos-sclo-sclo/primary_db | 151 kB 00:13 elrepo | 2.9 kB 00:00 elrepo/primary_db | 682 kB 00:00 epel | 3.2 kB 00:00 epel/primary | 3.2 MB 00:01 epel 12522/12522 extras | 3.4 kB 00:00 extras/primary_db | 26 kB 00:00 librehat-shadowsocks | 3.0 kB 00:00 librehat-shadowsocks/primary_db | 6.8 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 1.2 MB 00:00
创建版本库目录: mkdir /home/svn/svnpro (路径随意(想放哪放哪),svnpro为自定义名字)14:28:28 root@localhost ~ $mkdir /home/svn/svnpro
创建SVN版本库: svnadmin create /home/svn/svnpro/project (版本库目录 + project(自定义名字))14:29:21 root@localhost ~ $svnadmin create /home/svn/svnpro/project
修改配置: cd /home/svn/svnpro/project/conf14:30:30 root@localhost ~ $cd /home/svn/svnpro/project/conf
修改authz: vi authz14:30:53 root@localhost /home/svn/svnpro/project/conf $vi authz
在最后加上以下内容:
[/] # (别打反了!!!) one = rw two = rw three = rw
格式:账号 = 权限
保存退出:按Esc退出键,之后键入:wq回车即可退出保存,以下编辑均是这种方式保存退出
修改passwd: vi passwd14:33:14 root@localhost /home/svn/svnpro/project $vi passwd
格式:账号 = 密码
[users] # harry = harryssecret # sally = sallyssecret one = 123 two = 123 three = 123
修改svnserve.conf: vi svnserve.conf14:35:31 root@localhost /home/svn/svnpro/project $vi svnserve.conf
[general] ### These options control access to the repository for unauthenticated ### and authenticated users. Valid values are "write", "read", ### and "none". The sample settings below are the defaults. 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 (去除前面#号) 或 password-db = /home/svn/svnpro/project/conf/passwd (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 (去除前面#号) 或 authz-db = /home/svn/svnpro/project/conf/authz (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 [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
开启防火墙:
多数情况下服务器安装完成,配置完成后,无法连接svn服务器,均是防火墙问题,按照下面3条命令逐一执行即可
添加3690端口(3690是SVN的端口)到防火墙: /sbin/iptables -I INPUT -p tcp --dport 3690 -j ACCEPT14:40:56 root@localhost ~ $/sbin/iptables -I INPUT -p tcp --dport 3690 -j ACCEPT
保存防火墙规则: /etc/init.d/iptables save
14:41:03 root@localhost ~ $/etc/init.d/iptables save iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
重新启动防火墙: service iptables restart14:41:16 root@localhost ~ $service iptables restart iptables:将链设置为政策 ACCEPT:filter nat [确定] iptables:清除防火墙规则: [确定] iptables:正在卸载模块: [确定] iptables:应用防火墙规则: [确定]
启动svn服务器: svnserve -d -r /home/svn/svnpro (版本库目录)14:41:43 root@localhost ~ $svnserve -d -r /home/svn/svnpro
查看SVN是否启动: ps -ef | grep svn或ps aux | grep svn14:41:54 root@localhost ~ $ps -ef | grep svn root 1234 1 0 11:17 ? 00:00:00 svnserve -d -r /home/svn/svnpro root 1233 4321 0 14:42 pts/0 00:00:00 grep svn
或
14:42:01 root@localhost ~ $ps aux | grep svn root 1234 0.0 0.0 123456 1200 ? Ss 11:17 0:00 svnserve -d -r /home/svn/svnpro root 1233 0.0 0.0 123455 864 pts/0 S+ 14:42 0:00 grep svn
若运行ps -ef | grep svn或ps aux | grep svn这两条命令中的任意一条得到上面的结果,则svn已启动
开发工具连接SVN:
svn://ip地址:3690/project(project为“创建SVN版本库”中自己自定的名字) 或
svn://ip地址/project
输入连接地址后会弹出用户名和密码的输入框,账号和密码在上面修改的passwd文件中,输入账号和密码,点击确定即可连接成功