Ubuntu 之旅(六)安装subversion(svn)+apache2

要使用svn+http控制访问,windows上面有很方便的VisualSVN Server ,linux就得自己搞svn和对应的web 服务器了。一般选择subversion + apache2。

以下内容摘录子网上并做了相应修改 :(michael是用户名,请做相应修改)

1、安装Apache2Subversion模块
在ubuntu软件中心里搜索“apache2”, 安装apache2, apache2-common, apache2-utils, apache2-doc(apache文档,推荐安装), libapache2-svn(Apache2Subversion模块)
2
、创建Subversion
创建目录:


    $ sudo mkdir -p /var/local/repos


创建Subversion库:


    $ sudo svnadmin create /var/local/repos


将所有权授予Apache(www-data), 使之能对库文件进行读写操作:-----应该可以省略此步,可在后面步骤3里面使用htpasswd2或者htpasswd命令设置用户名密码


    $ sudo chown -R www-data:www-data /var/local/repos


3
、配置Apache2(使用基本验证方式,即用户名和密码)
修改/etc/apache2/mods-available/dav_svn.conf, 将对应行改为:


     <Location /repos>
       DAV svn
       SVNPath /var/local/repos
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/dav_svn.passwd
       <LimitExcept GET PROPFIND OPTIONS REPORT>
         Require valid-user
       </LimitExcept>
     </Location>

注意:添加svn repository用户:

To create a user on the repository use, the following command:

sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd <username>

---注:有的不是htpasswd2 命令,而是htpasswd命令,可以去/usr/bin/下查到此命令。

Note that you should only use the -c option the FIRST time that you create a user. After that you will only want to use the -m option, which specifies MD5 encryption of the password, but doesn’t recreate the file.

Example:

sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd geek
New password:
Re-type new password:
Adding password for user geek

If you want to force all users to authenticate even for read access, add the following line right below the AuthUserFile line from above. Restart apache after changing this line.

Require valid-user


4
、重启Apache2


    # sudo /etc/init.d/apache2 restart


5
、打开浏览器,访问http://localhost/repos, 就可以看到Subversion库的网页。(当然,现在还没有任何东东,下面我们要导入一些文件)


6
、添加/home/michael/workspace中的文件到http://localhost/repos下的workspace目录


    $ svn import -m "
操作注释" /home/michael/workspace http://localhost/repos/workspace


7
checkout http://localhost/repos/workspace 中的文件到/home/michael/test


    $ svn checkout http://localhost/repos/workspace /home/michael/test

 

你可能感兴趣的:(subversion)