本次试用的linux发行版是Ubuntu 12.04.5 LTS
yaoliang@node2:~$ lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 12.04.5 LTSRelease: 12.04Codename: precise
需要安装的环境:
apache2
subversion
libapache2-svn
1、安装svn
yaoliang@node2:~$ sudo apt-get install subversion
2、创建仓库
yaoliang@node2:~$ sudo mkdir /srv/svnyaoliang@node2:~$ cd /srv/svnyaoliang@node2:/srv/svn$ sudo svnadmin create reposyaoliang@node2:/srv/svn$ sudo tree -L 2.└── repos ├── conf ├── dav ├── db ├── format ├── hooks ├── locks └── README.txt6 directories, 2 files
3、修改配置文件
yaoliang@node2:/srv/svn$ cd repos/conf/yaoliang@node2:/srv/svn/repos/conf$ lsauthz passwd svnserve.confyaoliang@node2:/srv/svn/repos/conf$ sudo vim svnserve.conf [general] anon-access = none # 匿名用户权限改为noneauth-access = writepassword-db = passwdauthz-db = authzrealm = My First Repositoryyaoliang@node2:/srv/svn/repos/conf$ sudo vim passwd[users]admin = admin # 使用明文的方式存放账号和密码yaoliang@node2:/srv/svn/repos/conf$ sudo vim authz[groups] admin = admin # 将admin用户加到admin组中[/] @admin = rw # admin组的权限为读写* = r # 其他权限为只读
4、测试
yaoliang@node2:/srv/svn/repos/conf$ sudo svnserve -d -r /srv/svnyaoliang@node2:/srv/svn/repos/conf$ sudo netstat -antp | grep svn tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 13900/svnserve
发现3690端口已启动。
-d:以守护进程的形式运行
-r: 指明仓库所在的目录
通过TortoiseSVN查看并上传文件进行测试
5、安装apache2和libapache2-svn
yaoliang@node2:~$ sudo apt-get install apache2 libapache2-svn
6、配置apache2
yaoliang@node2:~$ cd /etc/apache2yaoliang@node2:/etc/apache2$ lsapache2.conf conf.d httpd.conf mods-available ports.conf sites-enabled apache_ssl_pass.sh envvars magic mods-enabled sites-available
7、权限修改
yaoliang@node2:/etc/apache2$ sudo useradd svnuseryaoliang@node2:/etc/apache2$ sudo groupadd subversionyaoliang@node2:/etc/apache2$ sudo groupadd svnuser subversionyaoliang@node2:/etc/apache2$ sudo chown -R root:subversion /srv/svnyaoliang@node2:/etc/apache2$ sudo chown -R www-data.www-data /src/svn
8、修改配置文件
将mods-enabled中的dav_svn.load和dav_svn.conf全部注释掉,重写一个新的配置文件
yaoliang@node2:/etc/apache2$ sudo vim conf.d/subversion.conf# 导入模块LoadModule dav_svn_module /usr/lib/apache2/modules/mod_dav_svn.soLoadModule authz_svn_module /usr/lib/apache2/modules/mod_authz_svn.soDAV svn SVNParentPath /srv/svn SVNListParentPath on AuthType Basic AuthName 'SVN Authentication' AuthUserFile /etc/apache2/svn.passwd AuthzSVNAccessFile /etc/apache2/svn.authz Require valid-user
9、生成认证和密钥文件
# 生成密钥文件yaoliang@node2:/etc/apache2$ sudo htpasswd -c -m svn.passwd admin # 首次创建加 -cyaoliang@node2:/etc/apache2$ tail svn.passwd admin:$apr1$ZAA6soA3$8zZ5aApEP9WAN/KajN4rw1# 生成配置文件yaoliang@node2:/etc/apache2$ sudo vim svn.authz[groups] admin = admin[/]@admin = rw* = r[repos:/]@admin = rw* = r
10、重启apache和svn
yaoliang@node2:/etc/apache2$ sudo pkill svnserveyaoliang@node2:/etc/apache2$ sudo svnserve -d -r /srv/svnyaoliang@node2:/etc/apache2$ sudo /etc/init.d/apache2 restart
11、通过TortoiseSVN进行测试