Linux下配置SUBVERSION SVN

apache源代码压缩包 httpd-2.2.9.tar.bz2 svn源代码压缩包 subversion-deps-1.5.0.tar.bz2 subversion-1.5.0.tar.gz

安装apache 解压httpd-2.2.9.tar.bz2,进入解压后的文件夹,执行configure,命令如下 ./configure --enable-dav --enable-so --prefix=/opt/apache2, 其中,--enable-dav允许Apache提供DAV协议支持;--enable-so允许运行时加载DSO模块,前两个参数是必须要加的,--prefix 是安装的位置如果configure通过,接着执行 make && make install ,数分钟后就完事了,通过 /opt/apache2/bin/apachectl -k start 来启动,在浏览器中访问127.0.0.1,如果出现 It's Works!,那么说明安装成功。

安装subversion 分别解压subversion-deps-1.5.0.tar.bz2和subversion-1.5.0.tar.gz,解压后他们都在subversion-1.5.0这个文件夹下,然后执行configure,命令如下 ./configure --with-apxs=/opt/apache2/bin/apxs --with-apr=/opt/apache2 --with-apr-util=/opt/apache2 --prefix=/opt/subversion-1.5.0 其中,--with-apxs 用于生成apache httpd的mod_dav_svn和mod_authz_svn模块;--with-apr 和 --with-apr-util=参数指向 Apache 的安装根目录,而不是使用缺省的 SVN 安装包中自带的 apr ,否则如果你安装的 Apache 版本不同有可能导致 APR 库不匹配,出现类似 Can't set position pointer in file '/svn/test/db/revs/1': Invalid argument 的错误,--prefix 是安装的位置。注意,在configure的时候可能回出现 configure: error: no XML parser was found: expat or libxml 2.x required和configure: error: We require OpenSSL; try --with-openssl这两个错误分别通过下面的apt-get来安装确实的库, apt-get install libxml2 libxml2-dev  expat apt-get install openSSL libssl-dev 也可以在configure前先检查一下本地是否已经存在上述所需要的lib,dpkg -l | grep libxml2和dpkg -l | grep openssl configure通过后进行make,似乎在make的时候会出现一个Error,信息如下 /usr/bin/ld: cannot find -lexpat,好像找不到libexpat.so这个库文件,但是/usr/lib下有/usr/lib/libexpat.so.1,于是做了一个link,命令如下 ln -s  /usr/lib/libexpat.so.1 /usr/lib/libexpat.so 再执行make,就通过了,使用make install安装。

创建的Subversion的版本库假设我们把版本库建立在/opt/svnroot 目录下,那么在/opt/svnroot目录下执行mkdir repository新建版本库文件夹,通过svnadmin create repository/test命令可创建名为test的版本库。若创建成功,则subversion的安装便已成功完成。使用mkdir –p import/{trunk,branches,tags} 命令在/opt/svnroot目录下建立一个名为import的新文件夹,包含trunk、branches、tags 三个子目录。下面这条语句将把路径/opt/svnroot/import下的目录和文件导入到你创建的Subversion 仓库中去,提交后的修订版为1。 svn import /opt/svnroot/import file:///opt/svnroot/repository/test –m "Init repository" 这里/opt/svnroot/import可以使用相对路径,但file:///opt/svnroot/repository/test必须以绝对路径表示。

使用htpasswd 生成身份认证文件,具体命令如下: htpasswd -m  -c /opt/svnroot/repository/pwdfile user1 (-c 是生成pwdfile文件,如果文件存在就不用带 -c 参数) htpasswd -m  /opt/svnroot/repository/pwdfile user2 htpasswd -m  /opt/svnroot/repository/pwdfile user3 这样就创建了3个用户

创建授权文件授权文件用于确定每个用户对特定目录的操作权限,格式可参考版本库下的conf/authz(conf目录下的authz文件用于svnserve的授权,与我们所使用的mod_authz_svn的授权文件具有相同的格式)。因而我们可以直接把conf下的authz复制到我们想要的/opt/svnroot/repository目录下,然后加以修改。修改后的文件大概是如下: [groups] g_pm=user1 g_dev=user2 g_dev=user3

[test:/] @g_pm=rw @g_dev=r

[test:/trunk] @g_pm=rw @g_dev=r

[test:/branches] @g_pm=rw @g_dev=rw

[test:/tags] @g_pm=rw @g_dev=rw

修改目录的owner及权限 chown -R apache:apache /opt/svnroot chmod 700 /opt/svnroot chmod -R 700 /opt/svnroot/repository

修改apache的httpd.conf文件修改User和Group都为apache

在文件的最后加上 <location /svn>         DAV svn         SVNParentPath /opt/svnroot/repository/         AuthType Basic         AuthName "Subversion Repository"         AuthUserFile /opt/svnroot/repository/pwdfile         AuthzSVNAccessFile /opt/svnroot/repository/authz         Satisfy Any         Require valid-user </Location> 其中/svn表示一个url的模式,匹配形如http://host/svn的url;SVNParentPath 指定的目录下的所有项目都被subversion 认为是合法的版本库;AuthzSVNAccessFile为授权文件 ;AuthType 则制定了客户端身份认证机制,Basic表示http基本认证机制;AuthUserFile就是先前创建的密码文件;Satisfy Any 和Require valid-user告诉apache所有用户先使用匿名方式访问版本库,只有当访问控制策略要求一个真实的用户名时,apache才会对客户端进行身份验证,这是使用得最多的一种授权方式。

至此,subverion加apache2 安装配置就完成了!


一.安装apr跟apr-util
1.下载apr跟apr-util
apr-1.3.3.tar.gz   apr-util-1.3.4.tar.gz
2.解压
  tar zvxf apr-1.3.3.tar.gz
  tar zvxf apr-util-1.3.4.tar.gz
3.安装
  cd apr-1.3.3
  ./configure --prefix=/usr/local/apr
  make && make install

  cd apr-util-1.3.4
  ./configure  --with-apr=/usr/local/apr
  Make && make install

二.安装apache服务器:
1. 下载最新的apache 2.2.9
    httpd-2.2.9.tar.gz
2.解压
tar zvxf htt-2.2.9.tar.gz
3. 安装
  ./configure \
“--prefix=/usr/local/apache2” \
“ --enable-so” \
“--enable-dav” \
“--with-apr=/usr/local/apr/bin/apr-1-config” \
“--with-apr-util=/usr/local/apr/bin/apu-1-config”
  make
  make install

注意:--prefix指定安装目录,注意一定要加--enable-so是核心能够装载DSO和--enable-dav是安装mod_dav_svn.so跟mod_authz_svn.so这两个模块
4.测试
  打开浏览器输入http://服务器ip  如果出现
   It Works!
  Apache安装成功
三. 安装subversion
1. 下载最新的subversion-1.5.2
subversion-1.5.2.tar.gz
2. 安装
  ./configure \
“--prefix=/usr/local/subversion” \
“ --with-apxs=/usr/local/apache2/bin/apxs” \
“--with-apr=/usr/local/apr/bin/apr-1-config” \
“--with-apr-util=/usr/local/apr/bin/apu-1-config” \
“--with-ssl” \
“--with-zlib” \
“--enable-maintainer-mode”
make
make install

3. 为了方便使用subversion的命令,将subversion安装目录下的bin目录加入到Path中

四. 配置subversion
1.        创建账号密码文件
htpasswd –c /data/svn/passwd.conf apache
   输入密码,两次确认
  注意:第一次设置用户密码要加入 –c 这个参数
2.        创建资料库
首先要创建一个资料库(我使用单资料库的方式),使用svnadmin增加资料库
cd /usr/local/subversion/bin
     ./svnadmin create /data/svn/svnroot
到svnroot下看是不是多了文件,多了就是说明创建成功
五. 配置apache的httpd.conf
打开apache的conf/httpd.conf,安装subversion后,apache的conf/httpd.conf文件会自动增加了模块
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

相应的so文件也自动copy到了apache/modules。这些工作就不用自己动手了。

需要自己动手修改apache下的httpd.conf最后增加以下内容
<Location /svn>
DAV svn
SVNPath /data/svn/svnroot #版本库的目录
AuthType Basic
AuthName "Subversion repository" #欢迎语言
AuthUserFile /data/svn/passwd.conf  #密码文件
Require valid-user
</Location>

注意:
(1)        SVNPath一定要跟./svnadmin create /data/svn/svnroot的目录一样,要不晕死你
(2)        目录svnroot的权限设置成755
  
六. 验证安装
打开浏览器,输入地址为http://服务器ip/svn
出现登陆窗口,输入用户名跟密码, 见图一

如果可以正常打开如上页面则说明安装配置正常,可以正常使用了,在页面上可以看到由于目前资料库中没有内容,因此看到的内容为空。

七.导入数据到资料库
Cd /usr/local/subversion/bin
./svn import /要导入的目录 file:///data/svn/svnroot -m “说明文字”
重新打开浏览器,输入地址http://服务器ip/svn,输入用户名密码,出现

好了,成功!
附:安装过程中遇到的问题
1.        编译subversion时出现少expat库
解决:下载expat-2.0.0.tar.gz安装皆可
2.        安装subversion时,编译到最后会出现一段
configure: WARNING: we have configured without BDB filesystem support
大概是不能创建db格式的版本库
解决:这个没什么关系,一般不会有多大影响
3.        安装subversion时,make没问题,make install时出现
/usr/local/src/subversion-1.5.2/subversion/svnversion/.libs/lt-svnversion: error while loading shared libraries: libexpat.so.1: cannot open shared object file: No such file or directory
意思是找不到libexpat.so.1这个文件
运行 whereis libexpat.so.1
libexpat.so: /lib/libexpat.so.0 /usr/local/lib/libexpat.so /usr/local/lib/libexpat.so.1
解决:vi  /etc/ld.so.conf
加入libexpat.so.1的目录 /usr/local/lib/ 保存退出
运行ldconfig
4.        安装好了后,浏览器打开http://服务器ip/svn,登陆出现不了页面,出现:
<D:error> <C:error/> <m:human-readable errcode="2"> Could not open the requested SVN filesystem </m:human-readable> </D:error>
解决:这是httpd.conf里的<Locate svn>中的SVNPath指向错误没指到创建的资料库
     第四步的最后我强调的东西
5.        这是开始安装时会出现的错误,安装subversion时会出现找不到arp的问题
解决:在编译subversion时加入
     --with-apr=/usr/local/apr/bin/apr-1-config
--with-apr-util=/usr/local/apr/bin/apu-1-config


你可能感兴趣的:(apache,linux,浏览器,SVN,subversion)