Step 1☆ 執行安裝命令
yum install httpd mysql mysql-server php php-* yum install httpd-devel subversion mod_dav_svn mod_auth_mysql mod_ssl perl perl-CGI
Step 2☆ 启动服务、开启相关端口
service httpd start service svnserve start iptables -I INPUT -p tcp --dport 80 -j ACCEPT iptables -I INPUT -p tcp --dport 3690 -j ACCEPT iptables -I INPUT -p tcp --dport 3306 -j ACCEPT service iptables save
Step 3☆ 创建SVN目录及仓库
killall svnserve mkdir /home/svndata chmod -R 755 /home/svndata chown -R apache.apahce /home/svndata svnserve -d -r /home/svndata svnadmin create /home/svndata/test echo "/usr/bin/svnserve -d -r /home/svndata/" > /etc/rc.local
Step 4☆ 创建Apache认证文件及用户
htpasswd -cm /home/svndata/passwd username htpasswd -m /home/svndata/passwd test htpasswd -b /home/svndata/passwd username userpasswd ----修改用户密码
Step 5☆ 修改Subversion.conf
vim /etc/httpd/conf.d/subversion.conf LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.soDAV svn SVNParentPath /home/svndata AuthType Basic AuthName "Authorization Realm" AuthUserFile /home/svndata/apasswd AuthzSVNAccessFile /home/svndata/authz Require valid-user
Step 6☆ 添加在线修改用户功能
创建文件 cd /var/www/cgi-bin touch ChangePasswd.ini ChangePasswd.cgi ChangePasswd.log chmod 755 ChangePasswd.cgi chmod 666 ChangePasswd.log -rwxr-xr-x 1 root root 6184 4月 23 22:02 ChangePasswd.cgi -rw-r--r-- 1 root root 573 4月 23 21:55 ChangePasswd.ini -rw-rw-rw- 1 root root 298 4月 23 22:24 ChangePasswd.log
vim ChangePasswd.ini
[path]authuserfile=/home/svndata/passwdlogfile=/var/www/cgi-bin/ChangePasswd.log[setup]pwdminlen=6[html]title=SVN用户密码自助修改description=SVN用户密码自助修改yourname=用户名oldpwd=旧密码newpwd1=新密码newpwd2=确认新密码btn_change=修 改btn_reset=重 置changepwdok=成功修改密码changepwdfailed=修改密码失败servererror=服务器错误passmustgreater=新密码位数必须大于twopassnotmatched=两密码不一致entername=请输入用户名enterpwd=密码未输入errorpwd=你的密码不正确back=返回
vim ChangePasswd.cgi
#!/usr/bin/perl -wuse strict;use CGI;my $time = localtime;my $remote_id = $ENV{REMOTE_HOST} || $ENV{REMOTE_ADDR};my $admin_email = $ENV{SERVER_ADMIN};my $cgi = new CGI;my $pwd_not_alldiginal = "密码不能全为数字";my $pwd_not_allchar = "密码不能全为字符";my $user_not_exists ="该用户不存在";my $file_not_found ="文件不存在,请联系管理员";my $authuserfile;my $logfile;my $pwdminlen;my $title;my $description;my $yourname;my $oldpwd;my $newpwd1;my $newpwd2;my $btn_change;my $btn_reset;my $changepwdok;my $changepwdfailed;my $oldpwderror;my $passmustgreater;my $twopassnotmatched;my $entername;my $enterpwd;my $errorpwd;my $back;&IniInfo;if ($cgi -> param()){#8my $User = $cgi->param('UserName');my $UserPwd = $cgi->param('OldPwd');my $UserNewPwd = $cgi->param('NewPwd1');my $MatchNewPwd = $cgi->param('NewPwd2');if (!$User) {&Writer_Log("Enter no user name"); &otherhtml($title,$entername,$back);}elsif (!$UserPwd ) {&Writer_Log("Enter no OldPasswd"); &otherhtml($title,$enterpwd,$back); }elsif (length($UserNewPwd)<$pwdminlen) {&Writer_Log("Password's length must greater than".$pwdminlen); &otherhtml($title,$passmustgreater.$pwdminlen,$back);}elsif ($UserNewPwd =~/^\d+$/) {&Writer_Log("New Passwd isn't all diginal"); &otherhtml($title,$pwd_not_alldiginal,$back);}elsif ($UserNewPwd =~/^[A-Za-z]+$/) {&Writer_Log("New Passwd isn't all char"); &otherhtml($title,$pwd_not_allchar,$back);}elsif ($UserNewPwd ne $MatchNewPwd) {&Writer_Log("Two new passwords are not matched"); &otherhtml($title,$twopassnotmatched,$back);}else{if($authuserfile){#6open UserFile, "<$authuserfile" or die "打开文件失败:$!";while () {#5 my $varstr=$_; if($varstr =~/($User)/) {#3 my $eqpos =index($varstr, ":"); my $UserName = substr($varstr,0,$eqpos); my $cryptpwd = substr($varstr,$eqpos + 1,13); next if($UserName ne $User); if(crypt($UserPwd,$cryptpwd) eq $cryptpwd) {#a my $rc = system("/usr/bin/htpasswd -b $authuserfile $User $UserNewPwd"); if ($rc == 0) {#1 &Writer_Log( $User.":Change Passwd"); &otherhtml($title,$changepwdok,$back); }#1 else {#2 &Writer_Log( $User.":Change Passwd Failed"); &otherhtml($title,$changepwdfailed,$back); }#2 exit; }#a else {#b &Writer_Log("Old Passwd is Incorrect "); &otherhtml($title,$errorpwd,$back); }#b exit; }#3 else {#4 if(eof) { &Writer_Log($User.":no this user"); &otherhtml($title,$user_not_exists,$back); exit; } else {next;} }#4 }#5 close UserFile;}#6else{#7 &Writer_Log($authuserfile.":no found"); &otherhtml($title,$file_not_found,$back);}#7}}#8else{&Index_Html;}sub IniInfo{my $inifile = "/var/www/cgi-bin/ChangePasswd.ini";open CGI_INI_FILE, "<$inifile" or die "打开文件失败:$!";;while ( ){my $eqpos =index($_,'=');my $len = length($_);if ($_ =~/authuserfile/){$authuserfile= substr($_, $eqpos + 1, $len - $eqpos -2);}elsif ($_ =~/logfile/){$logfile= substr($_, $eqpos + 1);}elsif ($_ =~/pwdminlen/){$pwdminlen= substr($_, $eqpos + 1);}elsif ($_ =~/title/){$title = substr($_, $eqpos + 1);}elsif ($_ =~/description/){$description = substr($_, $eqpos + 1);}elsif ($_ =~/yourname/){$yourname = substr($_, $eqpos + 1);}elsif ($_ =~/oldpwd/){$oldpwd= substr($_, $eqpos + 1);}elsif ($_ =~/newpwd1/){$newpwd1= substr($_, $eqpos + 1);}elsif ($_ =~/newpwd2/){$newpwd2= substr($_, $eqpos + 1);}elsif ($_ =~/btn_change/){$btn_change = substr($_, $eqpos + 1);}elsif ($_ =~/btn_reset/){$btn_reset = substr($_, $eqpos + 1);}elsif ($_ =~/changepwdok/){$changepwdok = substr($_, $eqpos + 1);}elsif ($_ =~/changepwdfailed/){$changepwdfailed = substr($_, $eqpos + 1);}elsif ($_ =~/oldpwderror/){$oldpwderror = substr($_, $eqpos + 1);}elsif ($_ =~/passmustgreater/){$passmustgreater = substr($_, $eqpos + 1);}elsif ($_ =~/twopassnotmatched/){$twopassnotmatched = substr($_, $eqpos + 1);}elsif ($_ =~/entername/){$entername = substr($_, $eqpos + 1);}elsif ($_ =~/enterpwd/){$enterpwd= substr($_, $eqpos + 1);}elsif ($_ =~/errorpwd/){$errorpwd= substr($_, $eqpos + 1);}elsif ($_ =~/back/){$back = substr($_, $eqpos + 1);}}close CGI_INI_FILE;}sub Index_Html{print "Content-type: text/html\n\n";print < $title
$description
注意:新密码位数必需大于$pwdminlen,且为字母与数字组合END_OF_PAGE}sub otherhtml{print "Content-type: text/html\n\n";print <$_[0] $_[1]
END_OF_PAGE}sub Writer_Log{if($logfile){my $loginfo ="[".$time."] "." [".$remote_id."] "." || ".$_[0];open LOGFILE,">>$logfile" or die "Couldn't open LOG FILE for writing: $!";print LOGFILE ("$loginfo\n");close LOGFILE;}}
http://ip/cgi-bin/ChangePasswd.cgi
Step 7☆ SVN客户端测试
svn://ip/test http://ip/svn/test