Build the svn environment in Ubuntu-Apache

Source: Internet
Author: User
Tags svn client

Environment Description: Ubuntu server 12.04/svn1.6/apache2

1. Create an SVN group and user first:

Addgroud SVN

Useradd svn-G svn-M // Add the svn username,-G and specify the svn group in which it is located.-M also creates the home directory where the svn user is located.

Passwd SVN // set the svn User Password

 

2. Install apache2 and SVN Server

Sudo apt-Get install apache2

Sudo apt-Get install Subversion

Sudo apt-Get install libapache2-svn

After the above installation, you can directly access the Apache homepage, such as http: // localhost/

3. Create an SVN version Library

Sudo mkdir/var/SVN

Sudo svnadmin create/var/SVN/Repos

You can view all the folders and configuration files of the SVN version library in the/var/SVN/repos directory, such as conf?db=format=hooks=locks=readme.txt.

 

4. Configure and import the project

Sudo mkdir/opt/idbtest

Sudo mkdir/opt/idbtest/branches

Sudo mkdir/opt/idbtest/tags

Sudo
Mkdir/opt/idbtest/trunk

Import the project to the version Library: SVN
Import/opt/idbtest file: // var/SVN/repos/idbtest-M "Initial import" /// opt/idbtest indicates the project to be introduced. file: /// var/SVN/repos/idbtest indicates the version library of SVN, Which is initialized and introduced here.

 

5. Configure SVN to Apache for HTTP web access

Sudo
VI/etc/apache2/Apache. conf, paste the following file to the end of Apache. conf, as follows:

<Location/SVN>
Dav SVN
Svnpath/var/SVN/Repos
Authzsvnaccessfile/var/SVN/repos/CONF/authz
Authtype basic
Authname "Subversion repository"
Authuserfile/var/SVN/repos/CONF/passwd
Require valid-user
</Location>

Note: This configuration file tells Apache that the svn access path is related to the configuration file. Restart the Apache server, and then you can remotely access the server through http: // localhost/SVN.

Restart Apache server:/etc/init. d/apache2 restart

Of course, you need to verify the login user. Next we will introduce how to add SVN users.

 

6. Add SVN users

Htpasswd-C/var/SVN/repos/CONF/passwd test1 // then you will be prompted to enter the password. Of course, to create a SVN user for the first time, you must pass the-C parameter, you do not need to create the svn user for the second time.

Htpasswd/var/SVN/repos/CONF/passwd Test2 // create the second SVN user

Then you can access http: // localhost/SVN through these users, and you can checkout SVN on other PCs. The command line is as follows:

SVN checkout http: // localhost/SVN -- username test1 -- password 123456

Of course, you can also use the svn client tool checkout for convenience.

 

7. Problems Encountered

When I checkout to my client and execute the commit submit operation, the svn client reports: SVN: can't open file '/var/SVN/repos/testdemo/DB/txn-current-lock': Permission denied

When the above error occurs, you need to check the access permissions of the version library. It may be that the version library does not have the write permission, and the group and access permissions of the current version library are root, we need to change the Group permission of the version Library to the svn group permission, as follows:

Sudo chown-r SVN: SVN/var/SVN/Repos

Sudo chmod 777-r repos /*

Commit again, and everything is normal

 

8. user permission Control

The following configuration must be added to the Apache configuration file to enable Apache to obtain the svn permission Configuration:

Loadmodule dav_module modules/mod_dav.so
Loadmodule dav_fs_module modules/mod_dav_fs.so
Loadmodule dav_svn_module modules/mod_dav_svn.so
Loadmodule authz_svn_module modules/mod_authz_svn.so

SVN permission control is controlled through the directory structure. The control permissions are in the/var/SVN/repos/CONF/authz file. The example configuration is as follows:

The directory testdemo is introduced under my version library. There are three branches, tags, and trunk in testdemo, where trunk contains app, Doc, testdoc, and devdoc.

Edit VI/var/SVN/repos/CONF/authz

[Groups]

Admin = Admin

Develop = dev1, dev2

Tester = test1, Test2

[/] // Indicates the root directory of the version library. Admin has all the read and write permissions.

@ Admin = RW

[/Testdemo/trunk] // indicates the trunk file in the root directory of the version library, indicating that develop has the read and write permissions in this folder.

@ Develop = RW

[/Testdemo/trunk/testdoc] // indicates that the trunk file in the root directory of the version library indicates that tester has the read and write permissions in the folder, that is, develop has the read and write permissions.

@ Tester = RW

@ Develop = r

The preceding permission configurations are flexible and you can define them as needed. Then, you can control the access permissions of each role.

 

Appendix: in order to better control the configuration and management of the version library, we found that SVN is suitable, so we started to build a SVN server.

 

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.