Install and configure the Subversion server in Ubuntu

Source: Internet
Author: User
Tags svn client
The installation and configuration of the Subversion server under Ubuntu the company's Subversion server often shuts down automatically due to computer hardware reasons, so it is planned to reinstall a server. The original Subversion server was set up on Windows XP through VisualSVNServer... the installation and configuration of the Subversion server under Ubuntu the company's Subversion server often shuts down automatically due to computer hardware reasons, so it is planned to reinstall a server. The original Subversion Server was deployed on Windows XP through the VisualSVN Server. now we are considering taking this opportunity to migrate it to the Linux system. For Linux, I chose Ubuntu 12.04 LTS Server. during system installation, you can install LAMP together so that Apache can be directly used after the system installation is complete. This article records how to set up the Subversion Server on Ubuntu 12.04 LTS. we will introduce the data migration of the Subversion repository separately. Www.2cto.com the scope of this article involves accessing the Subversion file repository through the HTTP protocol. you need to install and configure the Web server. Apache2 is proven to work well with Subversion. The installation of Apache2 is beyond the scope of this article (assuming that Apache2 has been installed). However, this article still involves how to configure Apache2 to use Subversion. Similarly, to access the Subversion file repository through HTTPS, you need to install and configure the digital certificate in your Apache2, which is not covered in this article. Fortunately, the Subversion has been included in the main repository. Therefore, to install Subversion, you just need to simply run: $ sudo apt-get install subversion $ sudo apt-get install libapache2-svn server configuration through the above command that you have installed the required software package. Next, we will explain how to create a Subversion repository and how to set project access permissions. The Subversion repository can be placed in many locations to create a Respository. Two of the most commonly used Subversion repositories are/usr/local/svn and/home/svn. We chose to store the Subversion repository in/home/svn/repos, and suppose we need to create two repositories project1 and project2. Generally, create a user group named "Subversion", which is the owner of the directory where the Subversion repository is located. Use the following command to add a group to www.2cto.com and add the user to the group: $ sudo addgroup subversion $ sudo usermod-G subversion-a www-datawww-data is a user created specifically for running the web server and has been created in advance in the system. View the execution results of the preceding two commands: $ cat/etc/group | grep subversionsubversion: x: 1001: www-data. execute the following command to create the repository Directory: $ sudo mkdir-p/home/svn/repos/project1 $ sudo mkdir-p/home/svn/repos/project2 the following command is used to create a Subversion repository: $ sudo svnadmin create/home/svn/repos/project1 $ sudo svnadmin create/home/svn/repos/project2 set the repository user and group: $ sudo chown-R www-data: subversion/home/svn/repos/project1 $ sudo chown-R www-data: subversion/home/ Svn/repos/project2: The Subversion repository can be accessed in a variety of ways-either through a local hard disk or through various network protocols. In any case, the location of the file repository is always represented by a URL. Below are several different URL modes and their corresponding access methods: www.2cto.com file: // -- directly access the file repository http on the local hard disk: // -- access Apache2 Web server that supports Subversion through WebDAV protocol https: // -- similar to http: //, supports SSL-encrypted svn: // -- Access the svnserve server svn + ssh: // -- similar to svn: // through the built-in protocol, and support access through the WebDAV protocol through the SSH channel (http ://) web-based Distributed Authoring and Versioning is a communication protocol based on the HTTP 1.1 protocol. it extends HTTP 1.1 and adds some new methods in addition to GET, POST, HEAD, and other HTTP standard methods so that applications can directly read and write to the Web Server, write file locking is supported. (Locking) and Unlock (Unlock) can also support file version control. To configure Apache mod \ _ dav \ _ svn to access the SVN file repository through the WebDAV protocol, you must first configure the Apache 2 Web server. Add the following code snippet to the/etc/apache2/mod-available/dav_svn.conf file: DAV svn # Alternatively, use SVNParentPath if you have multiple repositories # under a single directory SVNParentPath/home/svn/repos AuthType Basic AuthName "Subversion repository" # specify the password file path AuthUserFile/etc/subversion for Basic user authentication /dav_svn.passwd # specify the path of the authorization configuration file accessed by the file repository AuthzSVNAccessFile/etc/subversion/dav_svn.authz # Require valid-user #   Restart the Apache2 Web server $ sudo service apache2 restart password file dav \ _ svn. passwd creation $ sudo htpasswd-c/etc/subversion/dav_svn.passwd user_name it will prompt you to enter the password. when you enter the password, the user will be created. The "-c" option indicates creating a new/etc/subversion/dav_svn.passwd file. Therefore, user_name indicates that the user is the only user in the file. If you want to add other users, remove the "-c" option: $ sudo htpasswd/etc/subversion/dav_svn.passwd other_user_name to authorize the configuration file dav \ _ svn. first, you need to load mod_authz_svn.so in the/etc/apache2/mod-enabled Directory to create a soft link .. /mod-available/authz_svn.load $ cd/etc/apache2/mod-enabled $ sudo ln-s .. /mod-available/authz_svn.load .. the content of the/mod-available/authz_svn.load file is LoadModule authz_svn_module/usr/lib/apache2/modules/mod_authz_svn.so. here I have specified three groups: design. The read and write permissions of the test group and design group. The test group only has the read permission. In addition, set an admin account. the administrator has read and write permissions on all projects. The content of the authorization file www.2cto.com/etc/subversion/dav_svn.authz is as follows: [groups] design = user1, user2, user3test = user4, user5 [project1: /] admin = rw @ design = rw @ test = r [project2:/] admin = rw @ design = rw @ tester = r if the following error occurs during Check in: can't open '/home/svn/myproject/db/txn-current-lock': Permission denied this is caused by incorrect users and groups of files, you can reset the user and group for the entire project directory: $ sudo chown-R www-data: subversion/home/svn/repos/project1 if you do not want to set the owner of the project directory to www-data For example, if you want to set root: $ sudo chown-R root: subversion/home/svn/repos/project1, you must add root to the subversion group: $ sudo usermod-G subversion-a root also sets the group attributes: $ sudo chmod-R g + rws/home/svn/repos/project1 then view the permissions and user and group information of the txn-current-lock file, which should be similar: $ ls-l/home/svn/myproject/db/txn-current-lock-rw-rwSr -- 1 root subversion 0 txn-current-lock now, the configuration of the Subversion server has been completed. with SVN client software, you can use http :// To access the two file repositories configured above.
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.