linux SVN服务迁移,目标服务器Red Hat8
整体关联图
操作
安装
yum install php httpd subversion mod_dav_svn -y
- 在/var/www/svn 新建config和repos目录
- 将SVN配置文件authz和passwd拷贝到/var/www/svn/config
- 将SVNadmin拷贝到/var/www/html/svnadmin
- chown -R apache.apache /var/www/html/svnadmin
- chmod 777 /var/www/html/svnadmin/data
- vi /etc/selinux/config 修改 selinux为disabled 然后reboot
vi /etc/sysconfig/svnserve
OPTIONS="-r /var/www/svn/repos"
vi /var/www/html/svnadmin/data/config.ini
[Common]
FirstStart=0
BackupFolder=./data/backup/
[Translation]
Directory=./translations/
[Engine:Providers]
AuthenticationStatus=basic
UserViewProviderType=passwd
UserEditProviderType=passwd
GroupViewProviderType=svnauthfile
GroupEditProviderType=svnauthfile
AccessPathViewProviderType=svnauthfile
AccessPathEditProviderType=svnauthfile
RepositoryViewProviderType=svnclient
RepositoryEditProviderType=svnclient
[ACLManager]
UserRoleAssignmentFile=./data/userroleassignments.ini
[Subversion]
SVNAuthFile=/var/www/svn/config/authz
[Repositories:svnclient]
SVNParentPath=/var/www/svn/repos
SvnExecutable=/usr/bin/svn
SvnAdminExecutable=/usr/bin/svnadmin
[Users:passwd]
SVNUserFile=/var/www/svn/config/passwd
[Users:digest]
SVNUserDigestFile=
SVNDigestRealm=SVN Privat
[Ldap]
HostAddress=ldap://192.168.136.130:389/
ProtocolVersion=3
BindDN=CN=Manuel Freiholz,CN=Users,DC=insanefactory,DC=com
BindPassword=root
CacheEnabled=false
CacheFile=./data/ldap.cache.json
[Users:ldap]
BaseDN=DC=insanefactory,DC=com
SearchFilter=(&(objectClass=person)(objectClass=user))
Attributes=sAMAccountName
[Groups:ldap]
BaseDN=DC=insanefactory,DC=com
SearchFilter=(objectClass=group)
Attributes=sAMAccountName
GroupsToUserAttribute=member
GroupsToUserAttributeValue=distinguishedName
[Update:ldap]
AutoRemoveUsers=true
AutoRemoveGroups=true
[GUI]
RepositoryDeleteEnabled=false
RepositoryDumpEnabled=false
AllowUpdateByGui=true
vi /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
#
# Example configuration to enable HTTP access for a directory
# containing Subversion repositories, "/var/www/svn". Each repository
# must be both:
#
# a) readable and writable by the 'apache' user, and
#
# b) labelled with the 'httpd_sys_content_t' context if using
# SELinux
#
#
# To create a new repository "http://localhost/repos/stuff" using
# this configuration, run as root:
#
# # cd /var/www/svn
# # svnadmin create stuff
# # chown -R apache.apache stuff
# # chcon -R -t httpd_sys_content_t stuff
#
#<Location /repos>
# DAV svn
# SVNParentPath /var/www/svn
#
# #Limit write permission to list of valid users.
# <LimitExcept GET PROPFIND OPTIONS REPORT>
# # Require SSL connection for password protection.
# # SSLRequireSSL
#
# AuthType Basic
# AuthName "Authorization Realm"
# AuthUserFile /path/to/passwdfile
# Require valid-user
# </LimitExcept>
#</Location>
<Location /svn>
DAV svn
SVNParentPath /var/www/svn/repos
SVNLISTParentPath on
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /var/www/svn/config/passwd
AuthzSVNAccessFile /var/www/svn/config/authz
Require valid-user
</Location>
- 启动
systemctl enable svnserve
systemctl start svnserve
systemctl enable httpd
systemctl start httpd
- 原服务器备份
/var/www/svn/dump.sh dump
- 拷贝dump目录到目标服务器
- 目标服务器加载
/var/www/svn/dump.sh dump
- chown -R apache.apache /var/www/svn
dump.sh脚本
is_exist(){
if [ ! -e $1 ]; then
return 1 #不存在
else
return 0 #存在
fi
}
printf(){
echo "$(date +%Y-%m-%d\ %H:%M:%S) ${1}"
}
ensure_dir(){
is_exist $1
if [ $? -eq "1" ] ; then
mkdir -p $1
fi
}
ensure_cmd(){
$1 -h > /dev/null
if [ $? != "0" ] ; then
exit 1
fi
}
dump_dump(){
local cmd=$1
local repos_dir=$2
local dump_dir=$3
ensure_dir $dump_dir
printf "Dump Start"
for project in ${project_array[*]}
do
is_exist $repos_dir/$project
if [ $? -eq "1" ]; then
echo "$project dump failed.Project not exists."
continue
fi
$cmd dump -q $repos_dir/$project > $dump_dir/$project.dump
echo "$project dump success."
done
printf "Dump End"
}
dump_load(){
local cmd=$1
local repos_dir=$2
local dump_dir=$3
ensure_dir $repos_dir
printf "Load Start"
for project in ${project_array[*]}
do
is_exist $dump_dir/$project.dump
if [ $? -eq "1" ]; then
echo "$project load failed.Dump file is not exists."
continue
fi
is_exist $repos_dir/$project
if [ $? -eq "0" ]; then
echo "$project load failed.Project is already exists."
continue
fi
$cmd create $repos_dir/$project
$cmd load -q $repos_dir/$project < $dump_dir/$project.dump
echo "$project load success."
done
printf "Load End"
}
getAllFileNamesByPath(){
local path=$1
local removeSuffix=$2
result_array=()
for file in $path/*
do
temp_file=`basename $file $removeSuffix`
result_array+=($temp_file)
done
echo ${result_array[*]}
}
help() {
echo "help: [dump|load]"
echo "dump:dump project to dump files"
echo "load:load project from dump files"
exit 1
}
repos_dir=/var/www/svn/repos # the dir of repos,update here
dump_dir=/var/www/svn/dump # the dir of dump,update here
project_array=
cmd=svnadmin
ensure_cmd $cmd
case "$1" in
"dump")
project_array=($(getAllFileNamesByPath $repos_dir))
dump_dump $cmd $repos_dir $dump_dir $project_array
;;
"load")
project_array=($(getAllFileNamesByPath $dump_dir .dump))
dump_load $cmd $repos_dir $dump_dir $project_array
;;
*)
help
;;
esac
问题
- svnadmin访问显示如下
vi /var/www/html/svnadmin/include/config.inc.php
注释掉如下代码
- svnadmin访问显示文件夹层级,而不是解析的php页面
启动php-fpm - 能访问到/svn,但是不能访问/svn下的项目
检查authz文件,权限可能有问题(与SVN版本有关,到了1.10的版本收缩了权限控制)
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。