Use Apache and WebSVN to build the SVN server in Ubuntu

Source: Internet
Author: User
Tags vps
Setting up svn servers on vps is a common task. This article briefly introduces how to use apache to build a svn server under Ubuntu and use websvn for online browsing. This document assumes that the reader has installed the dav_module and dav_svn_module plug-ins of svn, php, apache, and apache, assume that the user name is linuxidc, the website domain name is www.linuxidc.com, and the website storage location is "/home/linu

Setting up svn servers on vps is a common task. This article briefly introduces how to use apache to build a svn server under Ubuntu and use websvn for online browsing. This document assumes that the reader has installed the dav_module and dav_svn_module plug-ins of svn, php, apache, and apache, assume that the user name is linuxidc, the website domain name is www.linuxidc.com, and the storage location of the website webpage is "/home/linuxidc/www/www.linuxidc.com/public_html ".

Step 1: first create the corresponding files and folders.

 
1 mkdir ~/svn && cd ~/svn
2 mkdir repos
3 touch svn-auth
4 touch svn-policy

Step 2: Move the document library to the repos folder created above. Of course, you can also use "svnadmin create" to create a new version library. It is worth noting that in order for apache to process files normally, we need to change the ownership of the version library. The following command creates a version library named test and changes its owner to www-data managed by apache.

 
1 cd ~/svn/repos
2 svnadmin create test
3 chown -R www-data:www-data test

Step 3: Add users who can access the version library and set their passwords. The following command creates two users, linuxidc and alice, and sets their passwords respectively.

 
1 cd ~/svn
2 htpasswd svn-auth alice
3 htpasswd svn-auth linuxidc

Step 4: Set the permissions of users who can access the version library. Here, we use svn's "path-based authorization". For more information, see here. For example, if you change the svn-policy content to the following, linuxidc has the read and write permissions for all versions of the database, while alice only has the read permission for the test version database.

 
1 [/]
2 linuxidc = rw
3 [test:/]
4 alice = r

Step 5: Add the following content to the apache configuration file of www.linuxidc.com.

 
01
02   Options Indexes FollowSymLinks
03   DAV svn
04   SVNParentPath /home/linuxidc/svn/repos
05   SVNListParentPath on
06   AuthzSVNAccessFile /home/linuxidc/svn/svn-policy
07   Require valid-user
08   AuthType Basic
09   AuthName "linuxidc.COM SVN Server Access"
10   AuthUserFile /home/linuxidc/svn/svn-auth
11

So far, a simple and flexible svn server has been built. Linuxidc can use svn and. However, the online browsing function provided by apache is very limited. To better browse the version library online, we can use websvn.

Step 1: Go to http://www.websvn.info/download/to download the latest websvnand decompress it. Assume that all extracted files are stored in "/home/linuxidc/www/www.linuxidc.com/public_html/websvn.pdf.

Step 2: Copy websvn/include/distconfig. php and rename it to websvn/include/config. php.

 
1 cp ~/www/www.linuxidc.com/public_html/websvn/include/distconfig.php ~/www/www.linuxidc.com/public_html/websvn/include/config.php

Step 3: Open websvn/include/config. php and add the following settings. You can also perform other settings as needed.

  • $ Config-> parentPath ('/home/linuxidc/svn/repos ');
  • $ Config-> useAuthenticationFile ('/home/linuxidc/svn-policy ');
  • $ Config-> setBlockRobots ();

Step 4: Add the following content to the apache configuration file of www.linuxidc.com.

 
1
2   Require valid-user
3   AuthType Basic
4   AuthName "linuxidc.COM WebSVN Viewer Access"
5   AuthUserFile /home/linuxidc/svn/svn-auth
6

Finally, restart the apache server.

 
1 sudo /etc/init.d/apache2 restart

Now, we can use www.linuxidc.com/websvnto access the website. In addition, the access control permission we set earlier is still valid for it.

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.