ITeye博客

redhat enterprise 6.1下httpd+svn服务搭建记录

chenhaiyang · 2013-03-29 16:46 · SVN(unix/linux) · 开源软件 · Markdown

这两天配了个http+svn的服务器,从一开始的什么都不懂到最后可以svn commit,经历了一些波折。在网上查了大量的资料,有很多没有记住都是谁写的了。无法将我参考过的文章链接列出来,报歉!

以下是我安装配置的过程,以便以后需要的时候再次翻阅。现在记性太差了。。。。。

操作系统:Linux RHE_6.1 (redhat enterprise 6.1)

需要软件包:Apache(httpd), Subversion

 

一,安装必须软件

我已经将yum配置了本地仓库。

1. 安装Subversion:

yum install subversion.

 

2. 安装apache

yum install httpd mod_dav_svn mod_perl

 

二,配置目录及创建SVN库

 

个人推荐创建一个用户来管理所有的svn库。

1.创建SVN目录

 

创建一个专为SVN库所在的目录,便于以后管理。

cd /home

mkdir svnroot

 

创建版本库根目录(即之后配置中的SVNParentPath)

cd svnroot

mkdir repository

 

创建鉴权信息目录(即之后的authfile, authz.conf所在的目录)

mkdir auth

 

创建权根配置文件

cd auth

vi authz.conf

 

2. 创建svn仓库

cd repository

 

svnadmin create test

创建名为test的仓库

 

将整个SVN根目录的所有者更改为apache

chown -R apache.apache /home/svnroot

这个也很重要,否则无法提交。会提示没有权限。

 

初始化SVN目录:

mkdir tmpfolder

cd tmpfolder

mkdir doc

mkdir release

mkdir tag

mkdir branch

mkdir trunk

cd doc

mkdir requirement

mkdir design

mkdir pm

 

svn import /home/svnroot/repository/tmpfolder/ file:///home/svnroot/repository/test/ -m "init folder struct"

这样test工程就有如下目录结构了

test

--doc

----requirement

----design

----pm

--release

--tag

--branch

--trunk

 

三,配置服务

 

1. Httpd配置

 

1.1 修改httpd配置

cd /etc/httpd/conf/

vi httpd.conf

 

ServerName=xxx.xxx.xxx.xxx:80                         //如果没有域名,并且没有接入公网解析的话,这里添IP地址

 

在底部添加

<Location /svn>

DAV svn

SVNParentPath /home/svnroot/repository

#Satisfy Any

AuthType Basic

AuthName "xxxxx"

AuthUserFile /home/svnroot/auth/authfile

Require valid-user

AuthzSVNAccessFile /home/svnroot/auth/authz.conf

</Location>

 

这里采用"SVNParentPath"的方式,在一个连接下管理多个svn库

 

1.2 添加用户文件,并创建svn用户

htpasswd -c /home/svnroot/auth/authfile xxx                     //xxx为用户名

这里会在/home/svnroot/repository/下创建authfile文件,并且创建第一个用户xxx

之后添加用户则为:

htpasswd /home/svnroot/auth/authfile xxx2

 

1.3 将httpd设置为开机自启动。

检查/etc/rc.d/init.d/下是否已经有httpd文件,并且是否已经有可执行权限。

如果有则跳转1.3.2

1.3.1 制作开机启动脚本:

以下一段是节选自别人的内容

  在/etc/rc.d/init.d目录下编辑启动脚本。

  拷贝自动启动的服务程序到 /etc/rc.d/init.d 目录下:

  例如:将 appache2的驱动程序appachectl拷贝至/etc/rc.d/init.d目录下并改名为:httpd

  cp /usr/sbin/apachectl /etc/rc.d/init.d/httpd

  使用编辑器打开httpd文件,并在第一行#!/bin/sh下增加两行文字如下

  # chkconfig: - 85 15

  # description: Apache

  更改httpd文件执行权限:

  chmod 700 /etc/rc.d/init.d/httpd

1.3.2 将httpd注册到开机启动中

chkconfig --add httpd

chkconfig --level 3 httpd on

chkconfig --level 5 httpd on

 

2 SVN权限配置

 

2.1 配置svn权限

vi /home/svnroot/auth/authz.conf

 

顶部添加:

[groups]

Admin=xxx,xxx1

testuser=test1,test2

 

[/]

*=r

 

[test:/]

@Admin=rw

@testuser=rw

*=r

 

这个是设置用户对SVN各目录的权限的。

 

3 防火墙服务设置

 

3.1 SELinux设置

这个东东的详细情况我还没有去学习了解,目前情况下只好把它禁掉了,不然的话svn配置好后会出现不停的要求输入用户名和密码

即使用正确的用户名和密码也无法进入。

命令行提示是:

Authentication realm: <http://xxxxxxxxxxxx> AuthName

Password for 'Your user':

Authentication realm: <http://xxxxxxxxxxxx> AuthName

Username: 

Password for 'Your user':

Authentication realm: <http://xxxxxxxxxxxx> AuthName

Username: 

Password for 'Your user':

svn: OPTIONS of ''http://xxxxxxxxxxxx: authorization failed: Could not authenticate to server: rejected Basic challenge (http://xxxxxxxxxxxx)

 

查看SELinux的配置,看其是否是enforce的。

如果SELinux是enforce的话,会导致svn一直要求输入用户名和密码,并永远也通不过(即使用正确的用户名和密码)

修改/etc/sysconfig/selinux 将其改成 disable就好了。

 

3.2 iptables设置

如果你的iptables是开启的,并且并没有将80端口的访问打开的话那么你将连不上svn。

查看并设置自己的iptables设置,这里贴出我自己的:

-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

-A INPUT -p icmp -j ACCEPT

-A INPUT -i lo -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

-A INPUT -j REJECT --reject-with icmp-host-prohibited 

 

最后重启机器,svn就可以使用了。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。