ubuntu8.04 成功源代码安装 subversion1.5.0,apache2.2.9

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 安装配置就完成了!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章