linux下配置https协议 subversion版本控制

本文详细介绍如何在Linux环境下从源码安装配置Apache Web服务器、Subversion版本控制系统及BerkeleyDB,并实现HTTPS与SVN结合使用的方法。文章还提供了解决安装过程中常见问题的方案。

准备软件 :
httpd-2.2.16.tar.gz
openssl-0.9.7e.tar.gz
subversion-1.3.2.tar.gz

 

 

如果系统没有自带 OpenSSL (运行openssl 命令检查 )

则需安装OpenSSL

    tar -zxvf openssl-0.9.7e.tar.gz
    cd openssl-0.9.7e
    ./config --prefix=/usr/local/openssl
    make
    make install

 

 安装 apache

    tar -zxvf httpd-2.2.2.tar.gz
    cd httpd-2.2.2
    系统自带openssl 的话
    ./configure --prefix=/usr/local/apache --enable-dav --enable-so --enable-maintainer-mode --enable-ssl --with-ssl
    安装制定openssl 的话
    ./configure --prefix=/usr/local/apache --enable-dav --enable-so --enable-maintainer-mode --enable-ssl --with-ssl=/usr/local/openssl/bin
    make
    make install

 参考  ./configure --prefix=/usr/local/apache --enable-mods-shared=all --enable-ssl=shared --with-ssl=/usr/local/ssl

 

BerkeleyDB 安装不建议安装 ,必须按下面的命令来安装,否则报错 )

    tar -zxvf BerkeleyDB-db-4.3.29.tar.gz
    cd db-4.3.29/
    cd build_unix/
    ../dist/configure --prefix=/usr/local/BerkeleyDB --enable-compat185
    make
    make install

 

安装 subversion-1.3.2

    tar -xzvf subversion-1.3.2.tar.gz
    cd subversion-1.3.2
    { 如果subversion安装完后 启动有问题
    重新安装 subversion 将 apache 源码下的 apr 和 apr-util 替换调 subversion 下的 这两个包
    rm -rf apr*
    cp -rf ../httpd-2.2.2/srclib/apr* .
    }
    用系统文件格式 存储
    ./configure --prefix=/usr/local/subversion --with-apxs=/usr/local/apache/bin/apxs --with-ssl
    用berkeley-db 存储 (不建议)
    ./configure --prefix=/usr/local/subversion --with-apxs=/usr/local/apache/bin/apxs --with-ssl --with-berkeley-db=/usr/local/BerkeleyDB
    make
    make clean

 参考:
./configure --with-apxs=/usr/local/apache2/bin/apxs --prefix=/usr/local/subversion
--with-apr=/usr/local/apache2 --with-apr-util=/usr/local/apache2 --with-ssl --with-zlib
--enable-maintainer-mode

 

 

安装完后配置

1.修改apache配置文件 vi /usr/local/apache/conf/httpd.conf

放开注释 #Include conf/extra/httpd-ssl.conf

注意User daemon Group daemon 和 svn 库 用户权限一致

2.修改apache配置文件 apache/conf/extra/httpd-ssl.conf文件 <VirtualHost>标签下添加

    <Location /svn>
    DAV svn
    SVNParentPath /home/svnRepository
    AuthType Basic
    AuthzSVNAccessFile /home/svnRepository/authz
    AuthName "Subversion repositories"
    AuthUserFile /home/svnRepository/passwd
    Require valid-user
    </Location>

 3.创建用户验证文件 passwd:apache/bin/htpasswd -cb passwd cj c123
mv passwd /home/svnRepository/
mv /home/svnRepository/soak/conf/authz /home/svnRepository/

 

authz文件示例

 

    [groups]
    # harry_and_sally = harry,sally
    # [/foo/bar]
    # harry = rw
    # * =
    [/]
    cj=rw
    # [repository:/baz/fuz]
    # @harry_and_sally = rw
    # * = r

 

 4.创建SVN库

    cd subversion/
    bin/svnadmin create /home/svnRepository/testsvn
    chown -R daemon:daemon /home/svnRepository
    注意: daemon:daemon 对应于apache 配置文件中的
    User daemon
    Group daemon

 

5.生成密钥:
openssl genrsa -des3 -out server.key 1024        ( 记住输入的密码)

如果不要每次开启apache时输入密码,不要加参数 -des3
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

注意:密钥文件放置路径 和 apache/conf/extra/httpd-ssl.conf描述一致
SSLCertificateFile "/usr/local/apache/conf/server.crt"
SSLCertificateKeyFile "/usr/local/apache/conf/server.key"

 

示例 

    cd /usr/local/apache/conf

    openssl genrsa -des3 -out server.key 1024


    Generating RSA private key, 1024 bit long modulus
    ......++++++
    .............++++++
    e is 65537 (0x10001)
    Enter pass phrase for server.key:
    Verifying - Enter pass phrase for server.key:


    openssl req -new -key server.key -out server.csr


    Enter pass phrase for server.key:
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [GB]:Zh
    State or Province Name (full name) [Berkshire]:JS
    Locality Name (eg, city) [Newbury]:NanJing
    Organization Name (eg, company) [My Company Ltd]:linkage
    Organizational Unit Name (eg, section) []:linkage
    Common Name (eg, your name or your server's hostname) []:linkage
    Email Address []:linkage@linkage.com
    Please enter the following 'extra' attributes
    to be sent with your certificate request
    A challenge password []:4321
    An optional company name []:4321


    openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

    chmod 400 * 设置生成的3个文件只读权限

 

 

Linux下让编译安装的apache自动启动

    

  •  在RedHat|CentOS 系统中,有两种方法可以让Apache在系统启动时自动启动。

    第1种:在/etc/rc.d/rc.local中增加启动apache的命令,例如:/usr/local/httpd/bin/apachectl start

   

    第2种:将apache注册为系统服务

    首先将apachectl命令拷贝至/etc/rc.d/init.d目录下,改名为httpd

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

    # chkconfig: 35 70 30

    # description: Apache

    接着注册该服务

    chkconfig --add httpd

    一切OK了,启动服务

    service httpd start

    其中所增加的第二行中三个数字第一个表示在运行级别3和5下启动apache,第二、三是关于启动和停止的优先级配置,无关紧要。

 

  • Ubuntu 开机自动启动apache.

    1). 复制 /usr/local/apache/bin/apachectl   到/etc/init.d
    sudo cp /usr/local/apache/bin/apachectl   /etc/init.d/httpd
    2). 加载为服务
     sudo update-rc.d httpd defaults

 

 

 

问题 :

 

启动apache命令apache/bin/apachectl start

如:https 访问 svn 出现 500 错误

<D:error xmlns:D="DAV:" xmlns:m="http://apache.org/dav/xmlns" xmlns:C="svn:">
<C:error/>
<m:human-readable errcode="22">
Can't set position pointer in file '/home/svnRepository/soak/db/revs/0': Invalid argument
</m:human-readable>
</D:error>

将apache 源码下的 apr 和 apr-util 替换调 subversion 下的 这两个包 重新安装 subversion

 

 

解决

   Ubuntu系统  安装 apache  中 遇到 :

checking for SSL/TLS toolkit includes... configure: error: OpenSSL headers not found

configure: error: ...No recognized SSL/TLS toolkit detected

解决: sudo apt-get install openssl libssl-dev

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值