After several days of hard work, we have finally installed subversion + Apache on Linux and successfully accessed the version library through the HTTP and SVN protocols. Here we will share with you.
Installation environment:
OS: RedHat advanceserver 4 Update 4
Software required:
SVN: Subversion 1.4.3
Httpd: Apache httpd 2.2.4
APR: Apache apr 1.2.8
Apu: Apache apr-util 1.2.8
1. Download the source code:
Download the tar.gz package of the corresponding source code from the official website. After unpacking, prepare for compilation and installation:
2. Compile the source code:
Compile the source code in the following order:
(1) Apache apr
# Cd apr-1.2.8
#./Configure -- prefix =/usr/local/APR
# Make
# Make install
(2) Apache apr-util
# Cd apr-util-1.2.8
#./Configure -- prefix =/usr/local/APR-util -- With-Apr =/usr/local/APR
# Make
# Make install
(3) Apache httpd
# Cd httpd-2.2.4
#. /Configure -- prefix =/usr/local/apache2 -- enable-Dav -- With-Apr =/usr/local/APR -- With-Apr-util =/usr/local/APR- util
# Make
# Make install
(4) Subversion
# Cd subversion-1.4.3
#./Configure -- prefix =/usr/local/Subversion -- With-apxs =/usr/local/apache2/bin/apxs
# Make
# Make install
The above compilation is usually successful and the corresponding executable program is obtained.
Check the WebDAV for SVN module:
# Cd/usr/local/apache2/modules
Check mod_dav_svn.so and mod_authz_svn.so. If the above two modules are successfully compiled in step 1, you can see them.
3. Create SVN users:
# Groupadd SVN
# Useradd-G SVN
This account will be used for subsequent code library creation and maintenance.
4. Create a version Library:
Log On As an SVN user
Prepare environment variables:
$ Svn_home =/usr/local/Subversion
$ Export svn_home
$ Path = $ path: $ svn_home/bin
$ Export path
The above command creates the version library sandbox for testing:
$ Svnadmin create -- FS-type fsfs sandbox
You can also create a project version Library:
$ Svnadmin create -- FS-type fsfs Projects
Create a script to start Subversion:
$ Echo '/usr/local/subversion/bin/svnserve-d-r/home/SVN/'> startup. Sh
$ Chmod + x startup. Sh
$./Startup. Sh
Place the startup script in the Automatic startup script:
Modify the file as root:/etc/rc. d/rc. Local and add the following text:
Su-C/home/SVN/startup. Sh SVN
5. Configure Apache httpd
# Cd/usr/local/apache2/Conf
# Vi httpd. conf
Load the WebDAV for SVN module:
#
# Dynamic shared object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# Have To place corresponding 'loadmodule' lines at this location so
# Directives contained in it are actually available _ before _ they are used.
# Statically compiled modules (those listed by 'httpd-l') do not need
# To be loaded here.
#
# Example:
# Loadmodule foo_module modules/mod_foo.so
Loadmodule dav_svn_module modules/mod_dav_svn.so
Loadmodule authz_svn_module modules/mod_authz_svn.so
Add the last two lines (after the default compilation, configure will automatically add ):
Loadmodule dav_svn_module modules/mod_dav_svn.so
Loadmodule authz_svn_module modules/mod_authz_svn.so
Modify the default user who starts httpd:
#
# If you wish httpd to run as a different user or group, you must run
# Httpd as root initially and it will switch.
#
# User/group: The name (or # number) of the user/group to run httpd.
# It is usually good practice to create a dedicated user and group
# Running httpd, as with most system services.
#
# User daemon
# Group daemon
User SVN
Group SVN
</Ifmodule>
Set the httpd user and group to SVN, so that the HTTPd process can access the data of the version library.
Configure the VM in Apache HTTP Server:
Remove the comments of the VM in httpd. conf and edit/usr/local/apache2/CONF/extra/httpd-vhost.conf.
# Virtual Hosts
Include CONF/extra/httpd-vhosts.conf
Add the virtual host svn.yourcompany.com. Of course, this host name must use your own domain name.
# Vi/usr/local/apache2/CONF/extra/httpd-vhost.conf
<Virtualhost *: 80>
Serveradmin webmaster@svn.yourcompany.com
Servername svn.yourcompany.com
Errorlog logs/svn.yourcompany.com-error_log
Customlog logs/svn.yourcompany.com-access_log common
<Location/>
Dav SVN
Svnlistparentpath on
Svnparentpath/home/SVN
</Location>
</Virtualhost>
The purpose of this configuration is to use a URL like a http://svn.yourcompany.com/sandbox or a http://svn.yourcompany.com/projects to allow various clients to access files in that repository over HTTP.
6. user authentication and authorization
User authentication is used to verify the identity of the user who accesses SVN. Authorization is used to restrict the user's permissions and restrict the user's permission to read and write each directory or file. For details, see svn-related documents. HTTP authentication is slightly different from SVN authentication.