Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Construction of SVN Server (combined with Apache) under Centos6

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

What is Subversion?

(permanent address of this article: http://woymk.blog.51cto.com/10000269/1951937)

Subversion is a free / open source version control system (version control system, VCS), that is, Subversion can manage files and directories and their changes over time. This allows you to restore the old version of the data, or check the modification history of the data. Because of this feature, many people regard the version control system as a "time machine".

Subversion can operate across networks, which allows multiple users to work on different machines. To some extent, allowing users to modify and manage the same set of data in their own space can promote team collaboration, because the modification is no longer done on a single line, and the development speed is faster. Since all the work is documented, there is no need to worry that parallel development will degrade the quality of the software-if an incorrect change occurs, just undo that change.

Some version control systems are also software configuration management (software configuration management, SCM) systems. This system is cleverly designed to manage the source code tree and has many features related to software development-understanding programming languages and providing program building tools. But Subversion is not SCM, it is a general-purpose system that can manage any type of file collection. To you, these files may be source code files-to others, they may be a list of goods or digital movies.

II. The structure of Subversion

One end of the figure is the Subversion warehouse that stores all the version data, and the other is the Subversion client program, which manages the local mapping of some version data. Between the two ends, there are multiple access paths through the warehouse access (Repository Access) layer, some of which span the computer network and access the warehouse through the network server, while others access the warehouse directly without passing through the network.

III. Components of Subversion

Svn

Client command line tool

Svnversion

A tool for reporting the status of working copies (in terms of the version number of the project)

Svnlook

Tools that can directly check the warehouse

Svnadmin

Tools for creating, adjusting, or repairing Subversion repositories

Mod_dav_svn

Apache HTTP server plug-in, which allows users to access the warehouse over the network

Svnserve

A custom, stand-alone server program that can be run as a daemon or called by SSH, which is another way to allow users to access the warehouse over the network

Svndumpfilter

Program for filtering data flow of Subversion Warehouse dump

Svnsync

A program that can perform incremental mirror backups of repositories across the network

Svnrdump

Programs that can dump and load warehouse history across the network

Svnmucc

The tool supports URL-based operations on multiple repositories in a single commit without a working copy

IV. Preparation before installing Subversion

Install some commonly used dependency packages

Yum install-y make gcc gcc-c++ perl zlib-devel libaio libpng libpng-devel libjpeg-devel pcre-devel

Yum install-y libXpm-devel openssl openssl-devel libxml2-devel bzip2-devel.x86_64 libjpeg-turbo-devel

Yum install-y freetype freetype-devel libtool cmake ncurses-devel bison re2c curl-devel wget

Rpm-ivh "http://mirrors.sohu.com/fedora-epel/epel-release-latest-6.noarch.rpm"

Yum install-y libmcrypt-devel re2c unzip

Install the dependency packages required by Subversion

(for details, please refer to the official document: http://svn.apache.org/repos/asf/subversion/trunk/INSTALL)

1. Apache Portable Runtime 1.3 or newer

Cd / usr/localhost/src

Wget https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-1.5.2.tar.gz

Wget https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-util-1.5.4.tar.gz

Tar zxvf apr-1.5.2.tar.gz

Cd apr-1.5.2

. / configure-- prefix=/usr/local/apr

Make & & make install

Cd..

Tar zxvf apr-util-1.5.4.tar.gz

Cd apr-util-1.5.4

. / configure-prefix=/usr/local/apr-with-apr=/usr/local/apr

Make & & make install

2. Zlib

Http://www.zlib.net/

The current version downloaded is zlib-1.2.11.tar

Execute after decompression

. / configure

Make & & make install

3. Autoconf 2.59 or newer

Yum install autoconf-y

4. Libtool 1.4 or newer

Yum install libtool-y

5. Apache Serf library 1.3.4 or newer

Cd / usr/local/src

Wget http://archive.apache.org/dist/serf/serf-1.2.1.tar.bz2

Tar jxvf serf-1.2.1.tar.bz2

Cd serf-1.2.1

Yum install expat expat-devel-y

. / configure-- prefix=/usr/local/serf-- with-apr=/usr/local/apr-- with-apr-util=/usr/local/apr

Make & & make install

6. OpenSSL (OPTIONAL)

Yum install openssl-y

7. Berkeley DB 4.X (optional installation)

Yuminstall db4-y

8. Cyrus SASL library (OPTIONAL)

Yum-y install cyrus-sasl*

9. Dbus

Yum install dbus

10. Qt 4 (optional installation)

Yum install qt qt-devel

11. GLib 2 (Unix only, OPTIONAL)

Yum install glib2 glib2-devel

12. KDELibs 4 (optional installation)

Yum install kdelibs kdelibs-devel

13. Python 2.7or newer (https://www.python.org/)

(optional installation)

14. SQLite (REQUIRED)

Https://www.sqlite.org/download.html

Cd / usr/local/src

Wget http://www.sqlite.org/2017/sqlite-amalgamation-3180000.zip

Unzip sqlite-amalgamation-3180000.zip

Decompress it first, and then use it when installing subversion.

5. Install Apache Web Server (2.2.X or newer)

Download the source package

Cd / usr/local/src

Wget http://mirrors.sohu.com/apache/httpd-2.2.34.tar.gz

Tar zxvf httpd-2.2.34.tar.gz

Compile & install

Cd httpd-2.2.34

/ configure-- prefix=/webapp/apache2-- enable-dav--enable-dav-fs--enable-dav-lock-- enable-so-- enable-rewrite-- enable-modules=all-- enable-mods-shared=all-- with-mpm=prefork-- enable-maintainer-mode-- enable-ssl-- with-ssl-- with-pcre-- with-include-apr

Make & & make install

Configure apache

Cd / webapp/apache2/

Vi conf/httpd.conf

find

# ServerName www.example.com:80

Change to

ServerName localhost:80

Check the configuration file syntax

Bin/apachectl-t

Configure startup script

Cp / usr/local/src/httpd-2.2.34/build/rpm/httpd.init/etc/init.d/httpd

Note that there are three main areas in the file that need to be modified:

Httpd=$ {HTTPD-/webapp/apache2/bin/httpd}

Pidfile=$ {PIDFILE-/webapp/apache2/logs/$ {prog} .pid}

CONFFILE=/webapp/apache2/conf/httpd.conf

Please change the corresponding path according to your installation directory!

Then run the following command:

Chmod + x / etc/init.d/httpd

Chkconfig-add httpd

Chkconfig httpd on

/ etc/init.d/httpd start

Netstat-lnp | grep httpd

6. Install Subversion

Download address on the official website: http://subversion.apache.org/download.cgi

Here we download version 1.8.

Cd / usr/local/src

Wget http://mirrors.tuna.tsinghua.edu.cn/apache/subversion/subversion-1.8.18.tar.gz

Tar zxvf subversion-1.8.18.tar.gz

Copy the extracted SQLite to the subversion directory

Mv sqlite-amalgamation-3180000subversion-1.8.18/sqlite-amalgamation

Cd subversion-1.8.18

/ configure-- prefix=/webapp/subversion-- with-apr=/usr/local/apr-- with-apr-util=/usr/local/apr-- enable-mod-activation-- with-apache-libexecdir=/webapp/apache2/modules-- with-apxs=/webapp/apache2/bin/apxs-- with-serf=/usr/local/serf-- with-zlib

Make & & make install

Create a version library:

To create a version library, you must first determine which way to store the data. In Subversion, there are two ways to store the data in the version library, one is to store the data in the Berkeley DB database, and the other is to use ordinary files and use a custom format to store it, which is called FSFS.

Two kinds of version library data storage comparison table

The feature Berkeley DBFSFS is sensitive to operational interruptions; system crashes or permission issues can cause the database to be "clogged" and need to be restored periodically. Insensitive. Read-only load cannot be stored, platform independent, accessible from the network file system, version library size is slightly larger, smaller scalability: the number of databases in the revision tree, there are no restrictions on many ancient local file systems that have problems when dealing with thousands of entries in a single directory. Scalability: directories with more files are slower and faster: checking out the latest code is faster and slower: large submissions are slower, but time is allocated faster throughout the commit operation, but the final longer delay may cause client operations to time out group access processing is very sensitive to the user's umask settings, preferably by only one user. Insensitive to umask settings when the function matured in 2001, it was used in 2004.

After determining the specific data storage type, you can create a Subversion version library as long as you execute the svnadmin command on the command line, as follows:

Create a folder

Mkdir / webapp/svndata

PATH=$PATH:/webapp/subversion/bin

Execute the svnadmin command to create a version library and specify that the data is stored as FSFS

Svnadmin create-fs-type fsfs / webapp/svndata/data

If you want to specify Berkeley DB, replace fsfs with bdb

For Subversion versions later than 1.2, svnadmin defaults to using the fsfs file system backend to create a version library.

Ll / webapp/svndata/data/

Total dosage 24

Drwxr-xr-x. 2 root root 4096 July 28 07:29 conf

Drwxr-sr-x. 6 root root 4096 July 28 07:29 db

-Rafael, Rafe, Rafael. 1 root root 2 July 28 07:29 format

Drwxr-xr-x. 2 root root 4096 July 28 07:29 hooks

Drwxr-xr-x. 2 root root 4096 July 28 07:29 locks

-rw-r--r--. 1 root root 246 July 28 07:29 README.txt

The configuration files of the version library are stored in the conf directory, including user access control and access control.

The db directory stores all the version-controlled data that Subversion manages.

The hooks directory stores hook scripts and their templates (a version library event trigger)

The locks directory stores Subversion version library lock data

The format file records the layout version number of the version library.

Use the svn import command to import the project:

Svn import / tmp/ file:///webapp/svndata/data/-message "init"

Verify that the imported project is correct:

Svn list-- verbose file:///webapp/svndata/data/

View information about the latest revision:

Svnlook info / webapp/svndata/data

"--revision version number", which specifies the display of a revision:

Svnlook info / webapp/svndata/data-- revision1

Displays the specific tree structure of the version library, followed by the "--show-ids" option to specify a modified version of ID for each display element:

Svnlook tree / webapp/svndata/data/-- show-ids

Basic server configuration

Svnserve is a lightweight server that uses custom protocols to communicate with clients over TCP/IP. The client accesses the svnserve server through URL starting with svn:// or svn+ssh://.

Start the SVN server:

Svnserve-d-r / webapp/svndata

-I start as inetd

-d starts as a daemon

-r is used to specify the root path of the version library

Using TortoiseSVN on the client side, you can access the server in the following ways:

Svn:// Server IP/data

The configuration file description under the conf subfolder of the version library:

1.svnserve.conf

[general]

# anon-access = read # permissions for anonymous users

# auth-access = write # authenticate the user's permissions

Password-db = passwd # specify password file

# authz-db = authz # permission control file

# realm = My First Repository

Configuration and description of 2.passwd file

[users]

# harry = harryssecret

# sally = sallyssecret

The equal sign is preceded by a user name and followed by a password, which is in clear text. When you change svnserve.conf, you need to restart SVN, change the authz,passwd file, and do not need to restart.

Configuration and description of 3.authz file

[groups]

# harry_and_sally = harry,sally

The variable defined by groups is the group name. A user group can contain one or more users separated by commas. In the above example, harry_and_sally is a group.

Version library directory format:

[: / Project / Directory]

@ =

=

Among them, the box number can be written in a variety of ways:

[/], indicates the root directory and below. The root directory is specified when svnserve starts. The configuration of / webapp/svndata/, [/] here means to set permissions on all version libraries.

[data:/], which means to set permissions on the version library data

[date:/test], which means to set permissions on the test project in the version library data

[data:/test/aaa], which means to set permissions on the aaa directory of the test project in the version library data

The permission principal can be a user group, user, or *, and the user group is preceded by @, * to indicate all users.

Permissions can be w, r, rw, and null, which means there are no permissions.

Every parameter in authz should be written in the top box, and there can be no spaces at the beginning.

[/]

Kevin = rw

@ harry_and_sally = r

Note: the user name that appears in the permission profile must be defined in the user profile

Set passwd,authz file permissions

Chmod 600conf/ {passwd,authz} # is not necessary, you'd better change it.

4. Considerations for Checkout

After installing the client TortoiseSVN on windows, there is one thing to be aware of in the checkout version.

For example, if the command to create a project version library is # svnadmin create / svn/testversion1/

Command to start the svn service # svnserve-d-r / svn/

Then the URL to check out the version library on the client is: svn://xx.xx.xx.xx/testversion1/

If the command to start the svn service is svnserve-d-r / svn/testversion1/, then the URL checked out is: svn://xx.xx.xx.xx/

VII. Combination with Apache Http Server

Accessing the version library through the Http protocol is one of the highlights of Subversion. Using the Http protocol means that you can easily browse the entire version library by opening a browser and typing URL. Flexibility usually brings complexity, and the Http approach requires more configuration than the svnserve approach.

Configure apache

In order for Subversion to communicate with the dav module, you need to install the mod_dav_svn plug-in and add the following to the httpd.conf file of Apache:

LoadModule dav_module modules/mod_dav.so

LoadModule dav_svn_module modules/mod_dav_svn.so

DAV svn

SVNPath / webapp/svndata/data

Restart apache

/ etc/init.d/httpd restart

The browser enters "http:// server IP/data"

Display:

Data- Revision 1: /

This indicates that the mod_dav_svn module is working properly. If it cannot be displayed, please check the firewall and SELinx configuration.

You can turn off the firewall and SELinx temporarily (please configure the production environment according to the actual situation)

Iptables-F

Setenforce 0

You can use SVNParentPath instead of SVNPath

SVNParentPath / webapp/svndate indicates that each subdirectory under / webapp/svndata is a version library, which can be obtained by:

Http:// Server IP/svndata/data1

Http:// Server IP/svndata/data2

| |

| |

| |

Http:// Server IP/svndata/data10

To visit.

Permission settings:

1. Apache basic permission settings

The simplest client authentication method is through the HTTP basic authentication mechanism, which simply uses a user name and password to verify a user's claimed identity. Apache provides a htpasswd tool to manage acceptable user names and passwords.

Cd / webapp

Apache2/bin/htpasswd-c svndata/passwd user1

-c means to create a new password file

Vi apache2/conf/httpd.conf

Add the following to the Location tag:

AuthType Basic

AuthName "svn data"

AuthUserFile / webapp/svndata/passwd

Require valid-user

After saving, restart apache.

/ etc/init.d/httpd restart

You can replace "Require valid-user" with "Require user harry sally", meaning that only harry and sally can access the version library.

two。 Directory access Control with mod_authz_svn

Access permissions can be set in more detail by using the mod_authz_svn module.

Vi apache2/conf/httpd.conf

Check whether the mod_auth_svn module is loaded

LoadModule authz_svn_modulemodules/mod_authz_svn.so

Add the following

DAV svn

SVNParentPath / webapp/svndata

AuthType Basic

AuthName "svn data"

AuthUserFile / webapp/svndata/passwd

AuthzSVNAccessFile / webapp/svndata/accesspolicy

Satisfy Any

Require valid-user

AuthzSVNAccessFile points to the policy file of authz. Detailed permission control can be specified in this policy file, such as:

# two groups: group1, group2 [groups] group1= user1, user2group2 = user3, user4 # specify that all users have read permission under the root directory [/] * = r# append group1 group users have read and write permission @ group1= rw # give users user1 read and write permission under data [data:/] user1 = rw # prohibit all users from accessing / private directory [/ private] * = # give group2 group users read permission @ group2= r

If you want to configure each version library, use the following syntax:

[groups] project1 = user1, user2project2 = user3, user4 [data1:/] * = r @ project1 = rw [data2:/] * = r @ project2 = rw

In this way, the project1 group of project 1 can only write to the files under the data1 version library, but cannot modify the version library data2, and the project2 group of project 2 cannot modify the files of the data1 version library.

Remember to save and restart apache after modifying the configuration:

/ etc/init.d/httpd restart

In addition, the permissions of the corresponding directories should be modified to make them support apache running account writable.

Chown-R daemon:daemon / webapp/svndata/data

This account can be set in the apache configuration file httpd.conf:

User daemon

Group daemon

VIII. Testing

After the SVN server is installed and configured, it is tested with TortoiseSVN on the client side. The results are as follows:

Enter the user name and password according to the prompt

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report