日历

2017年十二月
« 9月    
 123
45678910
11121314151617
18192021222324
25262728293031

最近评论

    Unix企业应用

    FreeBSD下svn(subversion)的安装部署

     

    1 FreeBSD下svn(subversion)的安装部署
      1.安装db (用db存储方式时采用,用fsfs方式可省略此步骤)
    tar zxvf db-4.5.20.tar.tar
    cd db-4.5.20/build_unix
    sh ../dist/configure

    2.安装apache2(作为启动svn的服务)
    tar zxvf httpd-2.0.59.tar.tar
    cd httpd-2.0.59
    ./configure –prefix=/usr/local/apache2 –enable-mods-shared=all –enable-dav –enable-dav-fs –enable-so –with-berkeley-db=/usr/local/BerkeleyDB.4.5
      这时提示
        “checking for Berkeley DB… not found”
        “configure: error: Berkeley DB not found.”
        “configure failed for srclib/apr-util”
    找不到解决办法,配置改为:
      ./configure –prefix=/usr/local/apache2 –enable-mods-shared=all –enable-dav –enable-dav-fs –enable-so
    能正确编译,但不支持db了。
    make 
    make install
    vi /usr/local/apache2/conf/httpd.conf
    /usr/local/apache2/bin/apachectl start

    3.安装libxml(/usr/local/include/libxml2/libxml)
    tar zxvf libxml2-2.6.22.tar.gz
    cd libxml2-2.6.22
    ./configure
    make
    make install

    4.安装php(作为web页面显示svn库结构用,后面要用到php程序)
    tar zxvf php-4.4.7.tar.gz
    cd php-4.4.7
    ./configure –with-apxs2=/usr/local/apache2/bin/apxs
    make
    make install

    如果是安装php5的话,还需要先安装iconv组件:http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.11.tar.gz
    http://www.gnu.org/software/libiconv/#TOCdownloading
    然后安装iconv:
    $ ./configure –prefix=/usr/local
    $ make
    $ make install

    5、安装neon(使svn支持webdav,https加密的链接)。
      cp neon-0.25.5.tar.tar subversion-1.4.4
      tar zxvf neon-0.25.5.tar.tar
      move neon-0.25.5 neon
    注:下载到svn编译目录、解压、重命名即可。

    6、svn
     $ ./configure –with-apxs=/usr/local/apache2/bin/apxs –with-apr=/home/xuejiang/httpd-2.0.59/srclib/apr –with-apr-util=/home/xuejiang/httpd
    -2.0.59/srclib/apr-util/ –with-ssl –prefix=/usr/local/subversion

      配置neon/src/Makefile,将CFLAGS = -g -O2 改成 CFLAGS = -fPIC -g -O2 

      没有这一步的话,make时报错:/usr/bin/ld: /home/xuejiang/subversion-1.4.4/neon/src/.libs/libneon.a(ne_request.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC
    /home/xuejiang/subversion-1.4.4/neon/src/.libs/libneon.a: could not read symbols: Bad value

    解决办法:在neon/src/Makefile中添加CFLAGS = -fPIC,即:
      搜索CFLAGS,在前面添加-fPIC,
        CFLAGS = -g -O2 改成 CFLAGS = -fPIC -g -O2 
      
    然后:
      make 

      make install

    完毕。
    7、输入svn进行验证。
      可能会报错:“/libexec/ld-elf.so.1: /usr/local/lib/libexpat.so.1: unsupported file layout”
      这是你多次对svn进行make/install而导致/usr/local/lib目录下的svn*损坏,可以删除/usr/local/bin下的所有svn*开头的文件,make install成功后再拷贝到该目录下。

      输入svn –version命令,应该出现如下提示:
    svn, version 1.4.4 (r25188)
       compiled Jun 27 2007, 17:54:38

    Copyright (C) 2000-2006 CollabNet.
    Subversion is open source software, see http://subversion.tigris.org/
    This product includes software developed by CollabNet (http://www.Collab.Net/).

    The following repository access (RA) modules are available:

    * ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
      – handles ‘http’ scheme
      – handles ‘https’ scheme
    * ra_svn : Module for accessing a repository using the svn network protocol.
      – handles ‘svn’ scheme
    * ra_local : Module for accessing a repository on local disk.
      – handles ‘file’ scheme
    8、配置apache、svn、php:
      vi /usr/local/apache2/conf/httpd.conf 

      配置:1)找到 User nobody 一行,将nobody改为svn的管理员,如xuejiang。不改的话,都没有权限创建顶级目录。
        2)找到DirectoryIndex一行检查,可能需要手工添加:index.php,用以支持php
       3)添加:AddDefaultCharset GB2312 支持中文。
       4)可能需要手工添加:AddType application/x-httpd-php .php .phtml

    AddType application/x-httpd-php-source .phps
       5)添加<VirtualHost *:80>节点,指定ServerName(web访问地址)、DocumentRoot(php文件地址),并在其中添加子节点指定svn的访问控制文件:
            <Location /repos>
                DAV svn
                SVNParentPath /home/y/share/htdocs/repos
            AuthType Basic
                AuthName “subversion repository”
                AuthUserFile /home/y/share/htdocs/repos/passwd
            AuthzSVNAccessFile /home/y/share/htdocs/repos/access
                Satisfy Any
                Require valid-user
        </Location>

    配置完了,重启服务:/usr/local/apache2/bin/apachectl restart
    (可能会报错:httpd: apr_sockaddr_info_get() failed for qa-test.corp.yahoo.com
    httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName;
      解决:配置ServerName;
    如果无法启动,查:/usr/local/apache2/logs/error_log,如果出现错误:hostname nor servname provided, or not known: mod_unique_id: unable to find IPv4 address of “qa-test.corp.yahoo.com”
      解决办法1:注释掉LoadModel mod_unique_id.so这一句。
      解决办法2:原因可能是主机名和/etc/hosts文件解释不一样。办法:输入hostname命令,拷贝一下列出的主机名;然后vi /etc/hosts,改一下127.0.0.1一行对应的localhost.my.domain为该主机名。然后再启动一下就可以了。

    )
     配置svn:先svnadmin create /ydata/repos 创建一个库。
        cd /ydata/repos,将访问配置文件拷贝出来并重命名:cp conf/authz ./;mv anthz access
    用apache的htpasswd命令进行创建passwd和用户:/usr/local/apache2/bin/htpasswd -c passwd username;为了简单,创建一个文件chpasswd进行管理用户吧:vi chpasswd,
      输入:sudo /usr/local/apache2/bin/htpasswd -m passwd $@ 
      保存退出。

    配置php:主要是写一个php脚本,将repository库的内容、目录列出来。在apache配置文件指定的doc位置写一个index.php文件,内容大概如下:
      <html>
    <head>
    <title>Subversion Repositories</title>
    <style>
        .webFolderAnchor {behavior: url(#default#AnchorClick);}
    </style>
    </head>
    <body>

    <h2>Subversion Repositories</h2>
    <ul>
    <?php
        $svnparentpath = “/ydata/repos”;
        $svnparenturl = “http://svntest.bj.corp.yahoo.com/repos“;
    #    $svnparenturl = “http://svn.yahoo-inc.com/repos“;
        $viewcvsparenturl = “/viewcvs”;

        $dh = opendir( $svnparentpath );
        if( $dh ) {
            while( $dir = readdir( $dh ) ) {
                $svndir = $svnparentpath . “/” . $dir;
                $svndbdir = $svndir . “/db”;
                if( is_dir( $svndir ) && is_dir( $svndbdir ) ) {
                    echo “<li> <a href=\”” . $svnparenturl . “/” .  $dir . “\”>” . $dir . “</a>\n”;
    #                      . ” [<a href=\”” . $viewcvsparenturl . “/” . $dir . “\”>viewcvs</a>]\n”;
                }
            }
            closedir( $dh );
        }
    ?>
    </ul>
    </body>
    </html>

    评论已关闭。