Build an apache + svn server in centos

Source: Internet
Author: User

This article describes in detail how to build the svn server in centos5. Including apache and subversion installation and some simple configurations.

  • InstallApache HTTP Server

Apache: http://www.apache.org/dist//httpd/httpd-2.2.20.tar.gz

Decompress the package through the tar-zxvf httpd-2.2.20.tar.gz, enter the decompressed folder, and execute

./configure --enable-dav --enable-so --prefix=/usr/local/apache2

Among them,-enable-dav allows Apache to provide DAV protocol support;-enable-so allows the DSO module to be loaded at run time, the first two parameters must be added, and-prefix is the installation location. If configure passes, run

make && make install

It will be finished in a few minutes. start It through/usr/local/apache2/bin/apachectl-k start and access 127.0.0.1 in the browser. If It's Works appears !, The installation is successful.

  • Install Subversion

  • Subversion

Subversion download two files: subversion-1.6.17.tar.bz2and subversion-deps-1.6.17.tar.bz2, which are http://subversion.tigris.org/downloads/subversion-1.6.17.tar.bz2http://subversion.tigris.org/downloads/subversion-deps-1.6.17.tar.bz2

Decompress subversion-1.6.17.tar.bz2and subversion-deps-1.6.17.tar.bz2 separately. After decompression, they are all in the subversion-1.6.17 folder and then execute configure. The command is as follows:

./configure --with-apxs=/opt/apache2/bin/apxs --with-apr=/usr/local/apache2 --with-apr-util=/usr/local/apache2 --prefix=/usr/local/subversion-1.6.7

The-with-apxs is used to generate the mod_dav_svn and mod_authz_svn modules of apache httpd. The-with-apr and-with-apr-util = parameters point to the installation root directory of Apache, instead of using the apr self-contained in the default SVN installation package, otherwise, if the Apache version you install is different, the APR library may not match, an error similar to Can't set position pointer in file '/svn/test/db/revs/1': Invalid argument occurs, and-prefix is the installation location. Some databases may not be found in the middle. Use yum as prompted. After configure is successful, compile and install it, that is

make && make install

If no error is reported, svn is successfully installed.

  • How to Create a version library for Subversion

Suppose we create a version library under the/opt/svnroot directory, then run mkdir repository in the/opt/svnroot directory to create a version library folder, you can use the svnadmin create repository/test command to create a version library named test. If creation is successful, the installation of subversion is successful. Run the mkdir-p import/{trunk, branches, tags} command to create a new import folder in the/opt/svnroot Directory, which contains three subdirectories: trunk, branches, and tags. The following statement imports the directories and files in the path/opt/svnroot/import to the Subversion repository you created, and the submitted version is 1.

svn import /opt/svnroot/import file:///opt/svnroot/repository/test -m "Init repository"

Here/opt/svnroot/import can use relative paths, but file: // opt/svnroot/repository/test must be expressed in absolute paths.

  • Use htpasswd to generate an Identity Authentication file. The command is as follows:

Htpasswd-m-c/opt/svnroot/repository/pwdfile user1 (-c is used to generate the pwdfile file. If the file exists, the-c parameter is not required) htpasswd-m/opt/svnroot/repository/pwdfile user2htpasswd-m/opt/svnroot/repository/pwdfile user3
  • Create an authorization file that controls User Permissions

The authorization file is used to determine the operation permissions of each user on a specific directory. For the format, see conf/authz in the version Library (the authz file in the conf directory is used for authorization by svnserve, the format is the same as that of the mod_authz_svn authorization file ). Therefore, we can directly copy the authz under the conf file to the/opt/svnroot/repository directory we want and then modify it. The modified file is roughly as follows:

[groups]g_pm=user1g_dev=user2,user1[test:/]@g_pm=rw@g_dev=r[test:/trunk]@g_pm=rw@g_dev=r[test:/branches]@g_pm=rw@g_dev=rw[test:/tags]@g_pm=rw@g_dev=rw

G_pm and g_dev define two user groups. A user belongs to a user group and sets the corresponding permissions of the user group in each directory. r read-only and w can be modified, that is, you can modify the code of the svn version library.

  • Configure apache

Modify the directory owner and permissions

chown -R apache:apache /opt/svnrootchmod 700 /opt/svnrootchmod -R 700 /opt/svnroot/repository

Modify the httpd. conf file of apache and set both User and Group as apache. Add the following code at the end of the file:

<location /svn> DAV svn SVNParentPath /opt/svnroot/repository/ AuthType Basic AuthName "Subversion Repository" AuthUserFile /opt/svnroot/repository/pwdfile AuthzSVNAccessFile /opt/svnroot/repository/authz Satisfy Any Require valid-user</Location>

/Svn indicates a url pattern, which matches URLs in the form of http: // host/svn. All projects in the directory specified by SVNParentPath are considered as legal version libraries by subversion; authzSVNAccessFile is the authorization file; AuthType sets the client identity authentication mechanism. Basic indicates the Basic http authentication mechanism; AuthUserFile is the previously created password file; satisfy Any and Require valid-user tells all apache users to access the version library anonymously first. apache will authenticate the client only when the access control policy requires a real user name, this is the most used authorization method.


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.