Ubuntu 12.04
使用首次创建的用户wkr登录,用户根目录/home/wkr/。
- 安装svn
sudo apt-get install subversion
- 开启svn服务器
svnserve -d
检查是否开启:ps aux | grep svnserve
若出现如下内容:
wkr 6537 0.0 0.0 13784 956 ? Ss 16:18 0:00 svnserve -d
wkr 7593 0.0 0.0 5784 864 pts/0 S+ 21:57 0:00 grep –color=auto svnserve
表示服务已开启。(注意:一定要有第1行,只有第2行说明服务未启动)
- 建立仓库
svnadmin create /var/svnrepos/repos1
理论上,仓库可以建立在任何目录中。
- 修改配置文件
编辑 svnserve.conf
gedit /var/svnrepos/repos1/conf/svnserve.conf
把anon-access = read,auth_access = write和password-db = passwd,authz-db = authz 的注释去掉,还有[general]的注释也要去掉(这个默认没有注释)。
注:当你去掉注释的时候,不要简单的把前面的#去掉,要把前面的空格一块去掉,不然在Eclipse中使用的时候会出现配置文件格式错误的问题。
- 修改帐户文件
gedit /var/svnrepos/repos1/conf/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
user1 = pass1 # 输入你定义的用户名和密码,密码显然没有加密
- 修改授权文件
gedit /var/svnrepos/repos1/conf/authz
修改或者输入下面2行:
[repos1:/]
user1 = rw
其中,repos1是仓库名称,user1是用户名,rw代表读写。
- svn开机自启动
进入/etc/init.d/目录
cd /etc/init.d/
创建/编辑svnd脚本文件
sudo gedit svnd
#!/bin/bash
# chkconfig: 34 30 70
# description: svnserve startup
if [ ! -f “/usr/bin/svnserve” ]
then
echo “svnserve startup: cannot start: file /usr/bin/svnserve doesn’t exists or cannot access.”
exit
fi
case “$1″ in
start)
echo “Starting svnserve…”
/usr/bin/svnserve -d –root /path/to/svnrepos
echo “started.”
;;
stop)
echo “Stoping svnserve…”
killall svnserve
echo “stopped”
;;
restart)
$0 stop
$0 start
;;
*)
echo “Usage: sudo service svnd {start|stop|restart}”
exit 1
esac
执行下面命令,svnserve即可开机自启动
sudo chmod a+x /etc/init.d/svnd
sudo chkconfig –add svnd