Setup SVN server on Ubuntu 14.04
2016-07-12 14:10
453 查看
https://www.howtoforge.com/how-to-install-and-use-svn-with-apache-dav_svn-on-ubuntu-14.04
http://www.if-not-true-then-false.com/2010/svn-subversion-access-control-with-apache-and-mod-authz-svn/
Subversion is a popular open source version control system that enables users to record the history of source files and documents, and manage
files and directories over a period of time. It is akin to a tree of files being placed into a central repository on the lines of a regular file server, barring that each modification made to these files and directories is always remembered.
This tutorial explains the process of installing and using SVN on Ubuntu 14.04 as per steps outlined below.
At the outset, you must ensure that all the packages installed on your system are updated. The following command shall help you do that:
sudo apt-get update
To run a Subversion (SVN) server, you need all the requisite packages, and you need to key in the following command for the same:
sudo apt-get install subversion subversion-tools libapache2-svn
You are now geared up to for the next step.
Here, you are required to create a directory where all the repositories may be housed. It is advisable to choose a directory that is easily
accessible to your the managed backup service for obvious reasons. Please key in the following command to do the same:
sudo mkdir /home/svn
This brings you to the end of this step, and you may move on to the next one, as explained below.
As part of this step, users need to first create a new folder to create the test project, and subsequently create a repository for the same.
The following command shall help you do that:
sudo mkdir ~/test
sudo svnadmin create /home/svn/test -m 'initial project structure'
The aforementioned command shall create a new repository for you that would comprise the base file structure. You may now graduate to the next
step.
Once you have created the repository, please use the following command to add files into the test project:
cd ~/test
mkdir trunk tags branches
You are now ready to import these new directories into the test repository, using the following command:
sudo svn import ~/test file:///home/svn/test -m 'Initial project directories'
The above command lets you add and also commit the new directories into the repository, all in one go. Further, for Apache to access the SVN
repositories, the directory thus created (/home/svn directory) must necessarily be owned by the same user and also group that Apache runs as. More often than not, in Ubuntu, it happens to be www-data.
In order to change the directory owner, please use the following command:
sudo chown -R www-data:www-data /home/svn
The above command shall enable you to change the owner of the directory, and you may subsequently move on to the next step.
Using the following command, you would be able to enable the dav_svn
Apache module:
sudo a2enmod dav_svn
After having enabled this, you would be required to modify the Apache configuration file (as follows):
sudo nano /etc/apache2/apache2.conf
Right at the bottom of the file, please add the following lines, before saving the file by hitting Ctrl+X.
After having saved this, you must restart the Apache service so as to implement the changes, by using the following command:
sudo service apache2 restart
Moving on, you would now be in a position to browse through the test repository you created by opening the web browser in Firefox, and visiting
the following link:
http://127.0.0.1/svn/test.
Here, you would be able to view all the three directories, though they would all be empty. You may now proceed to the next step.
Before the users start committing the files to the test repository, they must ensure that only authorized users are able to view it. The current
settings, however, would allow unauthorized viewing, and checking out of the repository and its contents, in addition to checkout and committing of files by just about anyone. To secure the repositories, you must supply a username and a password before you
begin to view the repository/ perform any action on the same. To execute this, you must reopen apache2.conf,
and replace the SVN Location information with the following:
Further, you must create a password file by using the following command:
htpasswd -cm /etc/svn-auth disney
Upon keying in the above command, you would be prompted to enter and confirm your password, and subsequently your details would be saved. Next,
the Apache service must be restarted, and subsequently, the user would need to authenticate themselves before going about viewing the repositories.
For checking out the files contained within the repository into a new directory (let us call it Test2) within the home directory, you first
need to create the new directory before you may issue the checkout command (as explained below):
cd ~
mkdir test2
svn checkout http://127.0.0.1/svn/test/trunk test2
You may now start adding files into the directory. Once the files have been created, you must perform the SVN add command, and pass in individual
filenames as further arguments (as given below):
svn add index.php
svn add *
Once all the required files have been added, these may be committed using svn
commit -m 'commit message' , and further, the server may be updated using the SVN up command. This brings you to the end of the process!
Shell
Note: Use exactly same file and path name as used on subversion.conf file.
This example use /etc/svn-auth-users file.
On this guide, I use following /etc/svn-access-control file.
Shell
Add following type content to file:Shell
Previously created /etc/httpd/conf.d/subversion.conf file:
Shell
Add AuthzSVNAccessFile row to config:Shell
Finally /etc/httpd/conf.d/subversion.conf file should look something like following:
Shell
http://www.if-not-true-then-false.com/2010/svn-subversion-access-control-with-apache-and-mod-authz-svn/
1.1 SVN-An Overview
Subversion is a popular open source version control system that enables users to record the history of source files and documents, and managefiles and directories over a period of time. It is akin to a tree of files being placed into a central repository on the lines of a regular file server, barring that each modification made to these files and directories is always remembered.
1.2 Step-by-Step Guide on the Installation and Use of SVN on Ubuntu 14.04
This tutorial explains the process of installing and using SVN on Ubuntu 14.04 as per steps outlined below.
1.2.1 Step 1: Ensuring Up-to-Date Installed Packages
At the outset, you must ensure that all the packages installed on your system are updated. The following command shall help you do that:sudo apt-get update
1.2.2 Step 2: Downloading the Subversion, Subversion Tools and Libapache2 packages
To run a Subversion (SVN) server, you need all the requisite packages, and you need to key in the following command for the same:sudo apt-get install subversion subversion-tools libapache2-svn
You are now geared up to for the next step.
1.2.3 Step 3: Creating Subversion (SVN) Directory
Here, you are required to create a directory where all the repositories may be housed. It is advisable to choose a directory that is easilyaccessible to your the managed backup service for obvious reasons. Please key in the following command to do the same:
sudo mkdir /home/svn
This brings you to the end of this step, and you may move on to the next one, as explained below.
1.2.4 Step 4: Creating a Test Repository
As part of this step, users need to first create a new folder to create the test project, and subsequently create a repository for the same.The following command shall help you do that:
sudo mkdir ~/test
sudo svnadmin create /home/svn/test -m 'initial project structure'
The aforementioned command shall create a new repository for you that would comprise the base file structure. You may now graduate to the next
step.
1.2.5 Step 5: Adding Files into the Test Project
Once you have created the repository, please use the following command to add files into the test project:cd ~/test
mkdir trunk tags branches
You are now ready to import these new directories into the test repository, using the following command:
sudo svn import ~/test file:///home/svn/test -m 'Initial project directories'
The above command lets you add and also commit the new directories into the repository, all in one go. Further, for Apache to access the SVN
repositories, the directory thus created (/home/svn directory) must necessarily be owned by the same user and also group that Apache runs as. More often than not, in Ubuntu, it happens to be www-data.
In order to change the directory owner, please use the following command:
sudo chown -R www-data:www-data /home/svn
The above command shall enable you to change the owner of the directory, and you may subsequently move on to the next step.
1.2.6 Step 6: Configuration of Apache
Using the following command, you would be able to enable the dav_svnApache module:
sudo a2enmod dav_svn
After having enabled this, you would be required to modify the Apache configuration file (as follows):
sudo nano /etc/apache2/apache2.conf
Right at the bottom of the file, please add the following lines, before saving the file by hitting Ctrl+X.
DAV svn SVNParentPath /home/svn
After having saved this, you must restart the Apache service so as to implement the changes, by using the following command:
sudo service apache2 restart
Moving on, you would now be in a position to browse through the test repository you created by opening the web browser in Firefox, and visiting
the following link:
http://127.0.0.1/svn/test.
Here, you would be able to view all the three directories, though they would all be empty. You may now proceed to the next step.
1.2.7 Step 7: Securing the SVN Repositories
Before the users start committing the files to the test repository, they must ensure that only authorized users are able to view it. The currentsettings, however, would allow unauthorized viewing, and checking out of the repository and its contents, in addition to checkout and committing of files by just about anyone. To secure the repositories, you must supply a username and a password before you
begin to view the repository/ perform any action on the same. To execute this, you must reopen apache2.conf,
and replace the SVN Location information with the following:
DAV svn SVNParentPath /home/svnAuthType Basic
AuthName "My SVN Repositories"
AuthUserFile /etc/svn-auth
Require valid-user
Further, you must create a password file by using the following command:
htpasswd -cm /etc/svn-auth disney
Upon keying in the above command, you would be prompted to enter and confirm your password, and subsequently your details would be saved. Next,
the Apache service must be restarted, and subsequently, the user would need to authenticate themselves before going about viewing the repositories.
1.2.8 Step 8: Checking Out the Repository and Committing Files
For checking out the files contained within the repository into a new directory (let us call it Test2) within the home directory, you firstneed to create the new directory before you may issue the checkout command (as explained below):
cd ~
mkdir test2
svn checkout http://127.0.0.1/svn/test/trunk test2
You may now start adding files into the directory. Once the files have been created, you must perform the SVN add command, and pass in individual
filenames as further arguments (as given below):
svn add index.php
svn add *
Once all the required files have been added, these may be committed using svn
commit -m 'commit message' , and further, the server may be updated using the SVN up command. This brings you to the end of the process!
Setup SVN (Subversion) Access Control with Apache and mod_authz_svn
1. Change root user
Shell01234 | su -## OR ##sudo -i |
2. Add SVN (Subversion) users
Use following command:Shell0 1 2 3 4 5 6 7 8 9 10 11 12 | ## Create testuser ## htpasswd -c -m /etc/svn-auth-users testuser New password: Re-type new password: Adding password for user testuser ## Create testuser2 ## htpasswd -m /etc/svn-auth-users testuser2 New password: Re-type new password: Adding password for user testuser2 |
This example use /etc/svn-auth-users file.
3. Create SVN Access Control file
On this guide, I use following /etc/svn-access-control file.Shell
0123 | ## Open /etc/svn-access-control file with your favourite editor ##nano -w /etc/svn-access-control |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | [groups] testgroup = testuser1, testuser2 testgroup2 = testuser3, testuser4, testuser5 testgroup3 = testuser6, testuser7 [/] * = r @testgroup = rw testuser4 = rw [testrepo:/] @testgroup2 = rw testuser6 = rw [testrepo2:/trunk] @testgroup3 = rw testuser5 = rw [testrepo2:/tags] @testgroup3 = r testuser5 = rw |
4. Add AuthzSVNAccessFile to subversion server config
Previously created /etc/httpd/conf.d/subversion.conf file:Shell
0123456789101112 | LoadModule dav_svn_module modules/mod_dav_svn.soLoadModule authz_svn_module modules/mod_authz_svn.so <Location /svn> DAV svn SVNParentPath /var/www/svn AuthType Basic AuthName "Subversion repositories" AuthUserFile /etc/svn-auth-users Require valid-user</Location> |
0 1 2 | AuthzSVNAccessFile /etc/svn-access-control |
Shell
012345678910111213 | LoadModule dav_svn_module modules/mod_dav_svn.soLoadModule authz_svn_module modules/mod_authz_svn.so <Location /svn> DAV svn SVNParentPath /var/www/svn AuthType Basic AuthName "Subversion repositories" AuthUserFile /etc/svn-auth-users AuthzSVNAccessFile /etc/svn-access-control Require valid-user</Location> |
5. Restart Apache Web Server
Shell0 1 2 3 4 | /etc/init.d/httpd restart ## OR ## service httpd restart |
相关文章推荐
- [转] 32位 PL/SQL Develope r如何连接64位的Oracle 图解
- leetcode_c++:哈希:Bulls and Cows(299)
- Linux命令--wget(后面有实例)
- svchost.exe占用内存过高
- 详解Java中的clone方法:原型模式
- 【NLP】揭秘马尔可夫模型神秘面纱系列文章(四)
- jQuery.extend 函数详解
- ubuntu 16.04 LTS 下Robomongo 无法输入中文的问题
- unity 控制旋转的方法
- hdu -3926-简单判同构并查集
- 淘宝顶端的通知样式 .
- css--伪类:first-child
- html5常用js简介之二
- Android Studio 之aar
- 远程桌面卡
- 修改Reachability检测2g、3g、4g网络
- Android Studio出现:Your project path contains non-ASCII characters.....
- eclipse package,source folder,folder区别及相互转换
- 第6章 Linux的档案管理与目录配置
- HDOJ 1004 Let the Balloon Rise