windows下快速安装可以通过http和https访问的subversion服务器

来源:互联网 发布:生物为什么要繁衍 知乎 编辑:程序博客网 时间:2024/06/05 17:28
1、下载apache2.0.54.msi,完全安装,选择安装路径至E:/  (别担心,实际上装出来是E:/apache2/)
2、下载svn-1.2.3-setup.exe,完全安装,选择路径至E:/SVN

提示:如先安装了svn再安装Apache,需要手工打开以下模块调用:

LoadModule dav_svn_module "E:/SVN/Subversion/bin/mod_dav_svn.so"
LoadModule authz_svn_module "E:/SVN/Subversion/bin/mod_authz_svn.so"

并把相应的文件从svn的安装目录拷贝到apache的modual目录

3、编辑E:/apache2/conf/httpd.conf在最后增加以下内容:

#islq add for svn server
<Location /svn>
    DAV svn
    SVNParentPath e:/svntest #SVN的项目数据库存放目录
    #our access control policy
    AuthzSVNAccessFile e:/ca/access/file
   
    #try anonymous access first,resort to real
    #authentication if necessary.
    #Satisfy Any
    Require valid-user #匿名不准访问
   
    #how to authenticate a user
    AuthType Basic
    AuthName "服务器需要身份验证:"
    AuthUserFile e:/ca/access/svn-auth-file
</Location>
#islq add end

4、添加用户验证文件和目录权限控制文件:

用户验证文件 e:/ca/access/svn-auth-file需要用E:/apache2/bin/htpasswd来生成:
E:/Apache2/bin>htpasswd -mc svn-auth-file islq
New password: ******
Re-type new password: ******
Adding password for user islq
(关于htpasswd的详细说明请用不带参数的htpasswd命令来看帮助)
把生成的用户验证文件移动到E:/ca/access/目录下面
建立目录权限控制文件e:/apache2/access/file,直接编辑以下内容:
[/]
* = rw
[repository:/tags]
islq =

  • 目录访问权限的控制,可以设置组,详细设置参考:svn-book.pdf
  • 这里的文件名和路径要和httpd.conf后面添加的文件名和路径一致
  • 生成SVN项目数据库可以用"svnadmin create e:/svntest/repository",详细使用参考svn-book.pdf
  • 到这一步,已经可以通过Http来访问SVN了,http://localhost/svn/repository
 5、设置HTTPS访问:

下载Apache_2.0.55-Openssl_0.9.8a-Win32.zip解压
将modual/mod_ssl.so拷贝到Apache2的modual目录
将conf/ssl.conf拷贝到Apache2的conf目录
将bin目录下ssleay32.dll和libeay32.dll拷贝到c:/windows/system32/
编辑E:/apache2/conf/httpd.conf,去掉下面这一行前面的#注释,打开mod_ssl模块调用
LoadModule ssl_module modules/mod_ssl.so
另外在Listen 80的后面增加
Listen 443
在httpd.conf最后增加以下内容

# see http://www.modssl.org/docs/2.8/ssl_reference.html for more info
SSLMutex yes #我这里用SSLMutex sem不能工作,不懂
SSLRandomSeed startup builtin
SSLSessionCache none

#SSLLog logs/SSL.log #我这里打开就不能工作,不懂
#SSLLogLevel info
# You can later change "info" to "warn" if everything is OK

<VirtualHost 10.16.131.54:443>#your ip
SSLEngine On
SSLCertificateFile "E:/ca/server.crt"#create this file manual
SSLCertificateKeyFile "E:/ca/server.key"#create this file manual
</VirtualHost>

6、自己生成根证书:(参考:http://tud.at/programm/apache-ssl-win32-howto.php3)

下载一个配置文件http://tud.at/programm/openssl.cnf,拷贝到上面下载解压后的Apache_2.0.55-Openssl_0.9.8a-Win32.目录下的bin目录,打开命令行转到该目录下

建立证书签名请求和专用密钥:

openssl req -new -out server.csr -config openssl.cnf

Loading 'screen' into random state - done
Generating a 1024 bit RSA private key
.............................++++++
.............++++++
unable to write 'random state'
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) [AU]:CH
State or Province Name (full name) [Some-State]:GuangDong
Locality Name (eg, city) []:ZhongShan
Organization Name (eg, company) [Internet Widgits Pty Ltd]:ESWN Co
Organizational Unit Name (eg, section) []:TestGroup
Common Name (eg, YOUR name) []:10.16.131.54 (这里输入你的ip或域名)
Email Address []:islqislq@gmail.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:(这里直接回车)
An optional company name []:Digital Technology Company

从专用密钥上删除通行码(这可能会降低服务器安全性,但是方便点)

>openssl rsa -in privkey.pem -out server.key
Enter pass phrase for privkey.pem:(输入你上面设置的密码)
writing RSA key

建立自签名的证书

Apache_2.0.55-Openssl_0.9.8a-Win32/bin>openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650
Loading 'screen' into random state - done
Signature ok
subject=/C=CH/ST=GuangDong/L=ZhongShan/O=ESWN Co/OU=TestGroup/CN=10.16.131.54/em
ailAddress=islqislq@gmail.com
Getting Private key

建立一个DER-encoded证书(MS IE 4.0用户可以直接下载安装该证书,我现在用的浏览器可以直接安装上面生成的证书,这一步应该没有必要了吧)

openssl x509 -in server.crt -out server.der.crt -outform DER

将生成的server.crt和server.key移动到E:/ca/(对应httpd.conf中路径和文件名设置)

重新启动apache2,然后用https://10.16.131.54就可以通过https来访问了,如果不能启动服务,多半是httpd.conf中的设置路径和实际的路径不一致,或忘记拷贝某些文件了。

提示:XP下防火墙需要打开80和443端口