残缺极品 发表于 2015-8-1 11:25:40

Linux 安装SVN 整合Apache + 权限控制

  一:相关版本
subversion在安装的时候,要求相关软件的版本一致,而不是说软件版本最新就最好.下面是我安装的相关版本.
httpd-2.2.3.tar.gz
subversion-deps-1.4.0.tar.gz
subversion-1.4.0.tar.gz
  二:安装准备
# mkdir /subversion
# cp httpd-2.2.3.tar.gz /subversion/
# cp subversion-deps-1.4.0.tar.gz /subversion/
# cp subversion-1.4.0.tar.gz /subversion/
# cd /subversion/
# tar zxvf httpd-2.2.3.tar.gz
# tar zxvf subversion-deps-1.4.0.tar.gz
# tar zxvf subversion-1.4.0.tar.gz
  到这一步,如果是32位的linux系统,可以直接安装httpd了,如果地64位的linux,需要进行以下操作,进行重新编译:
1、删除安装目录下的configure文件,在我的环境中是httpd-2.2.6/configure
2、删除“httpd-2.26/srclib/apr-util/configure”
3、通过以下命令重建编译文件(以下命令在http-2.26/目录下运行)。
#./buildconf
通过以上重建编译文件,现在可以拥有64位的apr-util了
  三:httpd的安装.
# cd /subversion/httpd-2.2.3
# ./configure --enable-dav --enable-so --prefix=/usr/local/apache2/ --enable-maintainer-mode
  (注意以上命令,参数不能随意减少,否则有可能出现一些未知的错误
如果是上面经过重建编译文件的64位Linux,使用如下命令:
#./configure --enable-dav --enable-so --prefix=/usr/local/apache2/ --enable-maintainer-mode --with-expat=builtin

  # make
# make install
# cd /usr/local/apache2/bin/
# ./apachectl start   (该命令可能会出现类似 Could not reliably determine the server's fully qualified domain name, using 192.168.0.71 for ServerName的错误,不用管它,服务实际上已经启动了 停止和重启也一样)
这个时候,打开浏览器,输入http://localhost/,如果浏览器出现It Works,则说明httpd安装成功了.
  四:subversion的安装
# cd /subversion/subversion-1.4.0
# ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-apr=/usr/local/apache2/ --with-apr-util=/usr/local/apache2/ --prefix=/usr/local/subversion --with-ssl --with-zlib --enable-maintianer-mode
# make && make install
  (
如果出现错误:make: *** Error 1
解决方法 在neon/src/Makefie 的 CFLAGS中增加 -fPIC选项 一定要加到最前面,例如 CFLAGS = -fPIC -g -O2
重新make

  五:建立和导入版本库
# cd /usr/local/subversion/bin/
# mkdir /repository
# ./svnadmin create --fs-type fsfs /repository/test
# ls /repository/test/   
//如果ls /repository/test/ 出现了下面的内容,就说明subversion安装成功了.
conf   dav   db   format   hooks   locks   README.txt
  导入版本库
# ./svn import /root/src/ file:///repository/test/ -m "initial import"
//命令成功执行,会有如下的提示信息,.
新增         /root/src/main.cpp
提交后的修订版为 1。
  六:修改目录权限
# cd /repository/test/
# chmod -R 777 *
  七:修改Apache的配置文件
1):打开apache2/conf/httpd.conf文件
2):修改httpd.conf文件,在文件的最后添加下面几行

DAV svn
SVNParentPath /usr/local/subversion/repository

3):保存退出
  上面指定的是,SVN不需要权限,即任何匿名用户都可以访问、修改、提交
在实际使用当中,需要有权限控制才行,因此,配置文件需要如下详细配置:
  进入apache2/bin目录,建立用户组和用户文件当然也可以是在其它文件夹,个人习惯把它放在这里方便操作
  建立用户组文件:
# touch authz
  在authz文件中写入如下内容,下面代码说明用户组admin有lyd,zzq,mc,yhl四个用户,admin组对[/]表示根目录具有读写权限 r代表读 w代表写:
  
admin = lyd,zzq,mc,yhl
[/]
@admin = rw
  创建用户,这里的用户需要在上面的用户组里面,才能有相应的权限:
htpasswd -cm pwd.txt lyd   第一次创建,加上 -cm 参数,需要创建用户文件pwd.txt,当然你也可以用别名字或后缀名
  htpasswdpwd.txt zzq   第二次创建,因为第一次已经创建了用户文件,所以只需要在用户文件中直接添加用户即可
  修改apache2/conf/httpd.conf文件,在最后添加下面代码,指定SVN的版本库位置及刚才创建的,权限需要使用的文件
  
DAV svn
SVNParentPath /usr/local/subversion/repository/
AuthzSVNAccessFile /usr/local/apache2/bin/authz
AuthType Basic
AuthName "Subversion"
AuthUserFile /usr/local/apache2/bin/pwd.txt
Require valid-user

  八:重启apache服务.
# cd /usr/local/apache2/bin/
# ./apachectl stop
# ./apachectl start
或者直接 restart
  起动SVN
/usr/local/subversion/bin/svnserve -d -r /repository
页: [1]
查看完整版本: Linux 安装SVN 整合Apache + 权限控制