windows2019部署VisualSVN

温馨提醒

提示:不要安装高版本的 VisualSVN,从 4.x 开始,有15个用户数量限制,需要购买 License

软件准备

  1. windows 2019
  2. VisualSVN-Server-3.9.7-x64.msi
  3. httpd-2.4.5-o111l-x86-vc15.zip
  4. php-7.3.31-Win32-VC15-x64.zip

安装配置 VisualSVN

安装

下一步,直到安装完成

配置 apache

1
2
3
4
# 解压 httpd 安装包
unzip httpd-2.4.51-o111l-x86-vc15.zip

# 把 htpasswd.exe 文件放到 VisualSVN/bin/ 目录下

配置 PHP

1
2
# 解压 php 安装包,把安装包放到 VisualSVN 安装路径下,并重命令为 php
最终路径为:C:\Program Files\VisualSVN Server\php

配置 httpd-custom.conf 文件

1
2
3
4
5
6
7
8
# 修改 C:\Program Files\VisualSVN Server\conf\httpd-custom.conf 文件
配置如下内容:

#php7 support
PHPIniDir "C:/Program Files/VisualSVN Server/php"
LoadModule php7_module "C:/Program Files/VisualSVN Server/php/php7apache2_4.dll"
AddType application/x-httpd-php .php .html .htm
#configure the path to php.ini

新建 index.php 文件

在 C:\Program Files\VisualSVN Server\htdocs 路径下新建 pw 文件夹,并在 pw 文件夹中新建 index.php 文件

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
$username = $_SERVER["PHP_AUTH_USER"];                    //经过 AuthType Basic 认证的用户名
$authed_pass = $_SERVER["PHP_AUTH_PW"];                   //经过 AuthType Basic 认证的密码
$input_oldpass = (isset($_REQUEST["oldpass"]) ? $_REQUEST["oldpass"] : "");     //从界面上输入的原密码
$newpass = (isset($_REQUEST["newpass"]) ? $_REQUEST["newpass"] : "");           //界面上输入的新密码
$repeatpass = (isset($_REQUEST["repeatpass"]) ? $_REQUEST["repeatpass"] : "");  //界面上输入的重复密码
$action = (isset($_REQUEST["action"]) ? $_REQUEST["action"] : "");     //以hide方式提交到服务器的action
if ($action!="modify") {
    $action = "view";
} else if ($authed_pass!=$input_oldpass) {
    $action = "oldpasswrong";
} else if (empty($newpass)) {
    $action = "passempty";
} else if ($newpass!=$repeatpass) {
    $action = "passnotsame";
} else{
    $action = "modify";
}
?>
 
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK">
    <title>Subversion Change Password</title>
</head>
<body>
 
<?php
//action=view 显示普通的输入信息
if ($action == "view") {
?>
<script language = "javaScript">
<!--
function loginIn(myform) {
    var newpass=myform.newpass.value;
    var repeatpass=myform.repeatpass.value;
 
    if (newpass=="") {
        alert("Please Enter Password");
        return false;
    }
 
    if (repeatpass=="") {
        alert("Please Re-Enter the Password");
        return false;
    }
 
    if (newpass!=repeatpass) {
        alert("The passwords entered twice are inconsistent, Please Re-Enter");
        return false;
    }
return true;
}
//-->
</script>
 
<style type="text/css">
<!--
    table {
        border: 6px solid #CCCCCC;
        background-color: #f9f9f9;
        text-align: center;
        vertical-align: middle;
        font-size: 10pt;
        line-height: 23px;
    }
    th {
        font-weight: bold;
        line-height: 20px;
        border-top-width: 1px;
        border-right-width: 1px;
        border-bottom-width: 1px;
        border-left-width: 1px;
        border-bottom-style: solid;
        color: #333333;
        background-color: f6f6f6;
    }
    input{
        height: 20px;
    }
    .button {
        height: 22px;
    }
-->
</style>
 
<br><br><br>
<form method="post">
<input type="hidden" name="action" value="modify"/>
<table width="290" cellpadding="3" cellspacing="8" align="center">
<tr>
<th colspan=2>Subversion Change Password</th>
</tr>
<tr>
<td>UserName:</td>
<td align="left"> <?php echo $username?></td>
</tr>
<tr>
<td>Old Password:</td>
<td><input type=password size=13 name=oldpass></td>
</tr>
<tr>
<td>New Password:</td>
<td><input type=password size=13 name=newpass></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><input type=password size=13 name=repeatpass></td>
</tr>
<tr>
<td colspan=2>
<input onclick="return loginIn(this.form)" class="button" type=submit value="Revise">
<input name="reset" type=reset class="button" value="Cancel">
<input onclick="window.location.href='/'" class="button" type="button" value="Return">
</td>
</tr>
</table>
</form>
<?php
} else if ($action == "oldpasswrong") {
    $msg="Old Password Error";
} else if ($action == "passempty") {
    $msg="Please Enter a New Password";
} else if ($action == "passnotsame") {
    $msg="The Passwords Entered twice are inconsistent, Please Re-Enter";
} else {
    $passwdfile="D:\Repositories\htpasswd";
    $command='"C:\Program Files\VisualSVN Server\bin\htpasswd.exe" -b '.$passwdfile." ".$username.' "'.$newpass.'"';
    system($command, $result);
    if ($result==0) {
        $msg_succ="UserName [".$username."] The password has been changed successfully, please log in with the new password";
    } else {
        $msg="UserName [".$username."] Password modification failed, The return value is ".$result.", Please contact the administrator";
    }
}
if (isset($msg_succ)) {
?>
<script language="javaScript">
<!--
alert("<?php echo $msg_succ?>");
window.location.href="/"
//-->
</script>
<?php
} else if (isset($msg)) {
?>
<script language="javaScript">
<!--
alert("<?php echo $msg?>");
window.location.href="<?php echo $_SERVER["PHP_SELF"]?>"
//-->
</script>
<?php
}
?>
</body>
</html>

增加修改密码的链接

修改 C:\Program Files\VisualSVN Server\WebUI\index.html 文件

1
2
3
4
5
6
7
8
9
# 原配置如下:
    <footer>
  Powered by <a href="https://www.visualsvn.com/server/">VisualSVN Server</a>. © 2019 VisualSVN Software Ltd.
  </footer>

# 修改后的配置如下:
  <footer id="footer">Powered by <a href='https://www.visualsvn.com/server/'>VisualSVN Server</a> | <a href='https://www.visualsvn.com/go/2197/'>Report a problem
    <br /><br /><a href="/pw/index.php">在线自助修改密码</a>
  </footer>

重启服务

重启 VisualSVN Background Job Service 和 VisualSVN Server 服务