在Linux下subversion和httpd(apache)安装配置

本文介绍如果实现Apache(httpd)+Subversion的配置。

Apache(httpd):

官方网址:https://httpd.apache.org/

The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.

The Apache HTTP Server ("httpd") was launched in 1995 and it has been the most popular web server on the Internet since April 1996. It has celebrated its 25th birthday as a project in February 2020.

Subversion:

官方网址:https://subversion.apache.org/

Subversion is an open source version control system. Founded in 2000 by CollabNet, Inc., the Subversion project and software have seen incredible success over the past decade. Subversion has enjoyed and continues to enjoy widespread adoption in both the open source arena and the corporate world.

Subversion is developed as a project of the Apache Software Foundation, and as such is part of a rich community of developers and users. We're always in need of individuals with a wide range of skills, and we invite you to participate in the development of Apache Subversion. Here's how to get started.

 

本文介绍如果实现在httpd(Apache)中集成subversion。本文操作的软件版本:httpd-server 2.4.x和subversion1.14.3。

 

在Linux下,可以把Subversion和httpd (Apache) 部署在一起,实现软修的代码仓库。

一.Linux中安装服务器端(Ubuntu)

1. 环境工具说明:

服务器linux环境:gcc,g++,apr。

 

2.源码安装apache(注意需要安装dav)

#tar zxvf httpd-2.0.58.tar.gz

#cd httpd-2.0.58

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

#make

#make install

此时会产生/usr/local/apache2目录

#apachetl start 或 systemctl start httpd

提示:在现代操作系统中安装,可以直接使用工具,比如:apt-get、yum.

apt-get update

apt-get install httpd

3. 从源码安装subversion

#tar zxvf subversion-1.1.1.tar.gz

#./configure --with-apxs=PATHTOapxs (这里要替换为apx的目录,即apr)

#make

#make install

也可以使用安装工具:apt-get install subversion

在httpd.conf中添加模块:

LoadModule dav_svn_module modules/mod_dav_svn.so

 

 

二.创建软件仓库

Subversion中建仓库需要使用SVN自带的命令,svnadmin

#svnadmin create 仓库目录

#svnadmin create /home/repos/mysoft

 

三.整合httpd和subversion

首先在httpd.conf配置文件中,添加:LoadModule dav_svn_module modules/mod_dav_svn.so 加载模块。

然后,添加配置,这里就要用到DAV:

DAV svn

SVNPath /home/repos/mysoft

 

四.设置SVN用户和权限

使用htpassword密码格式生成用户。

1. 创建用户:

进入/urs/local/apaceh2/bin,添加用户

# 以 -c 建立用户名和密码

# htpasswd -c /etc/httpd/svnpass usrname

New password: *****

Re-type new password: *****

Adding password for user usrname

#

2.用户权限添加

/pathto/httpd.conf的加入:

DAV svn

SVNPath /home/repos/mysoft

AuthType Basic

AuthName "My Subversion"

AuthUserFile etc/httpd/svnpass

Require valid-user

 

重新启动httpd后生效。

 

访问权限设置是按仓库进行设置。

比如:/home/repos/mysoft,可以在其子仓库目录中,设置权限,每个一个目录都有:conf/authz文件。

### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

该配置文件,用于设置哪个用户可以访问哪个目录,是否可以读写。

 
电话图标 点我咨询