Install the SVN server in CentOS and configure HTTPS connections

Source: Internet
Author: User
Tags openssl x509

Configure the SVN server on the 64-bit CentOS6.3 host and set to allow only HTTPS connections. Multiple repos sources can be configured. Each source has its own group and members for permission control.

Install related software

  • Install Apache

    Yum install httpd-devel


  • Subversion Installation

Yum install mod_dav_svn subversion
  • SSL Installation

Yum install mod_ssl openssl


Create a version Library

  1. # Mkdir/var/svn

  2. # Cd/var/svn

  3. # Svnadmin create myapp

  4. # Chown-R apache. apache myapp

  5. # Chcon-R-t httpd_sys_content_t myapp // selinux related


Similarly, I added another version library myapp2.


Modify the configuration file/etc/httpd/conf. d/subversion. conf and add the following content:

  1. <Location/repos>

  2. DAV svn

  3. SVNParentPath/var/svn

  4. AuthType Basic

  5. AuthName "Authorization Realm"

  6. AuthUserFile/var/svn/passwd // User File

  7. AuthzSVNAccessFile/var/svn/authz // user permission Control File

  8. Require valid-user

  9. </Location>


Note the related permissions for adding the/var/svn/passwd file. Otherwise, an error may occur. If the log file is/var/log/httpd/error_log, check the error log.


The passwd content of the user file can only be added using the htpasswd command

For example, add a user leon

  1. # Htpasswd-c/var/svn/passwd leon //-c indicates that a new file is created and does not need to be added later.

Similarly, I added other users hailong, gao, and wang.


User permission control file authz

  1. [Groups]

  2. Myapp = leon, hailong // The myapp project has two members: leon and hailong

  3. Myapp2 = wang, gao


  4. [Myapp:/]

  5. @ Myapp = rw // The myapp group has the read and write permissions of the myapp project. Others do not have the permission.


  6. [Myapp2:/]

  7. @ Myapp2 = rw


In this way, permission control is implemented.


Possible problems
1. Permission issues
View error logs and add related permissions. Pay attention to SeLinux caused by permission issues, you can temporarily disable SeLinux, method: setenforce 0, SeLinux management methods refer to CSDN website http://blog.csdn.net/haiong0707/article/details/8137633

2. Firewall Problems
Disable firewall or open related ports


Through the above configuration, SVN server access through HTTP is basically no problem, and then configure HTTPS access

  1. # Cd/etc/pki/tls/private

  2. # Open SSL genrsa-out my. key 1024

  3. # Openssl req-new-key my. key-out my. csr

  4. # Cd/etc/pki/tls/certs

  5. # Openssl x509-req-days 365-in/etc/pki/tls/private/my. csr-signkey/etc/pki/tls/private/my. key-out my. crt


The above steps must generate the required files in the relevant folder, ensure that the input command is correct, and ensure that the folder where the generated files are located is correct; otherwise, an error may occur later.


Modify the/etc/httpd/conf. d/ssl. conf file

  1. SSLCertificateFile/etc/pki/tls/certs/my. crt

  2. SSLCertificateKeyFile/etc/pki/tls/private/my. key


Modify the/etc/httpd/conf/httpd. conf file

  1. <Directory/>

  2. Options FollowSymLinks

  3. AllowOverride None

  4. SSLRequireSSL // Add this row

  5. </Directory>



Restart httpd

  1. # Service httpd restart


In this way, SVN can only be accessed through HTTPS, and multiple projects can be assigned personnel and permissions.


Possible problems

1. after HTTPS encryption is enabled for SVN, all WEB access is changed to HTTPS. For example, localhost cannot be accessed and you need to access https: // localhost. the configuration in the conf file is differentiated and will not be processed for the time being. Therefore, we recommend that this server be no longer used as a WEB server.


Bytes ----------------------------------------------------------------------------------------------------------------

Solution for localhost requiring https

Do not add SSLRequireSSL to httpd. conf and add it to subversion. conf.

  1. <Location/repos>

  2. DAV svn

  3. SVNParentPath/var/svn

  4. AuthType Basic

  5. AuthName "Authorization Realm"

  6. AuthUserFile/var/svn/passwd // User File

  7. AuthzSVNAccessFile/var/svn/authz // user permission Control File

  8. Require valid-user

  9. SSLRequireSSL // requires https encrypted access

  10. </Location>

In this way, only the/repos directory requires https encrypted access without affecting httpd as a web server.

Reprinted from: http://blog.csdn.net/haiong0707/article/details/8259235

In Linux, svn is often restored to a certain version due to the need of the pitfalls, the function should be switched back to a previous version. There are two ways to achieve this: Method 1: Use svn merge1) First svn up to ensure that the latest version is updated, such as 20; 2) then use svn log to view historical changes, find the version to be restored, such as 10. For more details, use svndiff-r [file or directory]; 3) Roll Back to version 10: svnmerge-r [file or directory]. note the order between version numbers. This is called reverse merge. 4) view the files in the current working version, such as test. differences Between Files in cpp and version 10: svn diff-r 10 test. cpp. If there is a difference, manually change it. 5) if there is no difference, submit: svn ci-m "back to r 10, xxxxx" [file or directory]. A new version is generated in the svn library, for example, 21. Method 2: Use svn up the first two steps, such as method 1, and then directly svn up-r 10. The current working version is version 10. However, note that a new version will not be generated in the svn repository. After the local svn is up, the new version will be returned.

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.