191145692 发表于 2017-1-7 08:01:27

Subversion 1.7.2 Apache 2.2

  首先下载 (svn-win32-1.7.2.zip):

http://sourceforge.net/projects/win32svn/files/1.7.2/
  解压缩到D盘。(D:\Subversion1.7)
  再下载(httpd-2.2.21-win32-x86-openssl-0.9.8r.msi)

http://httpd.apache.org/download.cgi
  推荐下载windows的解压缩版,这样不用安装,解压就可以用,msi安装版 总出现一个 服务在右下角不美观。
  安装到D盘。(D:\Apache2.2)
  1 从D:\Subversion1.7\bin 中将mod_authz_svn.so和mod_dav_svn.so复制到D:\Apache2.2\modules中
  2 从D:\Subversion1.7\bin 中将intl3_svn.dll libdb*.dll复制到D:\Apache2.2\bin中
  3 记事本打开D:\Apache2.2\conf\httpd.conf文件,把引用so模块的注释去掉。
  #LoadModule dav_fs_module modules/mod_dav_fs.so
  #LoadModule dav_module modules/mod_dav.so
  然后再把刚才从D:\Subversion1.7\bin中拷贝过去的mod_authz_svn.so和mod_dav_svn.so配置进去:
  LoadModule dav_svn_module modules/mod_dav_svn.so
  LoadModule authz_svn_module modules/mod_authz_svn.so
  然后在D盘创建一个 资源库总目录(D:\Repositories)
  里面创建 两个文本文件  (authz与htpasswd)用于存放资源库权限和用户名密码
  然后配置apache访问路径与规则:

<Location /svn>
DAV svn
SVNListParentPath on
SVNParentPath "D:/Repositories/"
#SVNIndexXSLT "/svnindex.xsl"
AuthName "www.sdinfotech.cn"
AuthType Basic
#AuthBasicProvider file
AuthUserFile "D:/Repositories/htpasswd"
AuthzSVNAccessFile "D:/Repositories/authz"
require valid-user
</Location>
 
<Location /svn>  与 /svn/ 在访问上略微不同,可以自己在ie上测试
    DAV svn                  通知Apache:哪个模块响应上述URL的请求,svn代表是Subversion模块。   
    SVNListParentPath on    对于Subversion1.3或者更高版本,显示所有SVNParentPath下的版本库。   
    SVNParentPath D:/ Repositories /通知Subversion需要查看的版本库位于D:/ Repositories /之下 
    SVNIndexXSLT "/svnindex.xsl"    使用该选项可以在用浏览器浏览时更好看。   
    AuthType Basic            激活基本认证,就是用户名/密码   
    AuthName "www.sdinfotech.cn"    用来说明何时弹出要求用户输入认证信息的认证对话框
    SSLRequireSSL         必须采用安全连接,https:// 方式访问   
AuthUserFile "D:/Repositories/htpasswd" 指定使用的认证密码文件  AuthzSVNAccessFile "D:/Repositories/authz" 指定Subversion版本库的访问控制文件的路径   
    Require valid-user      指定只有输入正确的用户/密码的用户才可访问本URL

   创建版本库(D:\Repositories\test)
  使用svn 命令:D:\Subversion1.7\bin\svnadmin create --fs-type fsfs D:\Repositories\test
  这样 在D:\Repositories\test 下就生成了一些文件,一个资源库就建好了,你还可以建立更多资源库,一个web项目一个资源库也是可以的。
  创建用户名:韩梅梅
  D:\Subversion1.7\bin\htpasswd -m D:\Repositories\htpasswd hanmeimei
  根据接下来的提示,输入 密码,这样信息就存储到了 D:\Repositories\htpasswd这个文件中,当然是加密的。
  编辑权限文件(D:\Repositories\authz )

                                                 创建两个组
    admin_group=hanmeimei
    user_group1=hanmeimei,luci,lintao
[/]                                                            跟目录的权限
    * = r                                                        所有人都可读
    @admin_group = rw                                admin_group组有读写权限
    boli =                                                       boli没有任何权限
                                                    test资源库的权限
    @admin_group = rw

   这时访问 http://localhost:80/svn/test输入用户名密码后已经可以访问了。
  开启 ssl
  创建证书:
  你可能需要 从http://tud.at/programm/openssl.cnf 下载这个配置文件 放到 D:\Apache2.2\conf 下




##1. 打开cmd, cd到D:/Apache2.2/bin
##2. 运行
openssl req -config ../conf/openssl.cnf -new -out my-server.csr
    (注意, my-server是自己起的名字, 以下步骤中提到的my-server也是自己起的名字)
这一步需要设置一系列的问题, 包括密码(这个密码要记住, 以后要用) 和其他的问题. 全部完成之后会生成一个my-server.csr和 privkey.pem 文件在bin文件夹中.
##3. 运行
openssl rsa -in privkey.pem -out my-server.key
此时要输入密码, 就是步骤2中设定的密码
##4. 运行
openssl x509 -in my-server.csr -out my-server.cert -req -signkey my-server.key -days 4000
这将创建一个4000天后才过期的证书
#5. 运行
openssl x509 -in my-server.cert -out my-server.der.crt -outform DER

全部运行过后这些命令会在bin文件夹中生成6个文件:
.cnt
privkey.pem
my-server.der.crt
my-server.scr
my-server.key
my-server.cert

 
运行的效果:

Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>cd D:\Apache2.2\bin

C:\Documents and Settings\Administrator>d:

D:\Apache2.2\bin>openssl req -config ../conf/openssl.cnf -new -out www.sdinfotec
h.cn.csr
Loading 'screen' into random state - done
Generating a 1024 bit RSA private key
................................................................................
....++++++
...........++++++
writing new private key to 'privkey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
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) :www.sdinfotech.cn
string is too long, it needs to be less than2 bytes long
Country Name (2 letter code) :www.sdinfotech.cn
string is too long, it needs to be less than2 bytes long
Country Name (2 letter code) :
State or Province Name (full name) :www.sdinfotech.cn
Locality Name (eg, city) []:
Organization Name (eg, company) :www.sdinfotech.cn
Organizational Unit Name (eg, section) []:www.sdinfotech.cn
Common Name (eg, YOUR name) []:www.sdinfotech.cn
Email Address []:tongwei@sdinfotech.cn

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:****
An optional company name []:www.sdinfotech.cn

D:\Apache2.2\bin>openssl rsa -in privkey.pem -out www.sdinfotech.cn.key
Enter pass phrase for privkey.pem:
writing RSA key

D:\Apache2.2\bin>openssl x509 -in www.sdinfotech.cn.csr -out www.sdinfotech.cn.c
ert -req -signkey www.sdinfotech.cn.key -days 4000
Loading 'screen' into random state - done
Signature ok
subject=/C=AU/ST=www.sdinfotech.cn/O=www.sdinfotech.cn/OU=www.sdinfotech.cn/CN=w
ww.sdinfotech.cn/emailAddress=tongwei@sdinfotech.cn
Getting Private key

D:\Apache2.2\bin>openssl x509 -in www.sdinfotech.cn.cert -out www.sdinfotech.cn.
der.crt -outform DER

D:\Apache2.2\bin>



   把这6个文件 放到 (D:\Apache2.2\conf\ssl)下面
  配置 ssl

 写道

用文本编辑器打开D:\Apache2.2/conf/httpd.conf
    1. 去掉下面设置行前面的#
LoadModule ssl_module modules/mod_ssl.so
    2. 去掉下面设置行前面的#
Include conf/extra/httpd-ssl.conf
    3. 用文本编辑器打开D:\Apache2.2/conf/extra/httpd-ssl.conf
    更改如下设置.
SSLMutexdefault
SSLCertificateFile "D:/Apache2.2/conf/ssl/my-server.der.crt"
SSLCertificateKeyFile "D:/Apache2.2/conf/ssl/my-server.key"

   接下来就可以测试了。
  用https 的方法访问,应该是 慢一些但是也稍微 安全了一点。
  把svn 添加为服务
  


添加系统服务,随系统启动:
sc create svnservicebinpath= "D:\Subversion1.7\bin\svnserve.exe --service --root D:\Repositories " displayname= "Subversion" depend= tcpip start= auto

删除服务:
sc delete svnservice

   添加apache 为服务:
  





1)运行

2)键入命令:cmd

3)进入Apache安装目录下的bin目录:cd D:\Apache2.2\bin

4)键入命令:httpd.exe -k install -n apache2.2

结果显示:

Installing the apache2.2 servece

The apache2.2 service is successfully installed.

删除Service

键入命令:httpd.exe -k uninstall -n apache2.2



 
页: [1]
查看完整版本: Subversion 1.7.2 Apache 2.2