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 |
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.
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.
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.
Step 5: Add the following content to the apache configuration file of www.linuxidc.com.
02 |
Options Indexes FollowSymLinks |
04 |
SVNParentPath /home/linuxidc/svn/repos |
06 |
AuthzSVNAccessFile /home/linuxidc/svn/svn-policy |
09 |
AuthName "linuxidc.COM SVN Server Access" |
10 |
AuthUserFile /home/linuxidc/svn/svn-auth |
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.
4 |
AuthName "linuxidc.COM WebSVN Viewer Access" |
5 |
AuthUserFile /home/linuxidc/svn/svn-auth |
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