搭建SVN服务器与Apache同步
–检查内存
[root@imagehost bin]# free -m
total used free shared buffers cached
Mem: 5928 4334 1594 0 201 3226
-/+ buffers/cache: 905 5023
Swap: 2015 0 2015
–测试安装环境
[root@imagehost bin]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.9 (Final)
Release: 5.9
Codename: Final
[root@imagehost bin]# uname -a
Linux imagehost 2.6.18-348.16.1.el5 #1 SMP Wed Aug 21 04:00:25 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
–开始安装
[root@imagehost bin]# yum install subversion -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.skyshe.cn
* extras: mirrors.skyshe.cn
* updates: mirrors.skyshe.cn
adobe-linux-x86_64 | 951 B 00:00
base | 1.1 kB 00:00
extras | 2.1 kB 00:00
updates | 1.9 kB 00:00
utterramblings | 2.3 kB 00:00
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package subversion.i386 0:1.6.11-12.el5_10 set to be updated
—> Package subversion.x86_64 0:1.6.11-12.el5_10 set to be updated
–> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================
Updating:
subversion i386 1.6.11-12.el5_10 base 3.1 M
subversion x86_64 1.6.11-12.el5_10 base 3.2 M
Transaction Summary
====================================================================================================================================================================================
Install 0 Package(s)
Upgrade 2 Package(s)
Total size: 6.4 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : subversion 1/4
Updating : subversion 2/4
Cleanup : subversion 3/4
Cleanup : subversion 4/4
Updated:
subversion.i386 0:1.6.11-12.el5_10 subversion.x86_64 0:1.6.11-12.el5_10
Complete!
–检查SVN版本
[root@imagehost bin]# svnserve –version
svnserve,版本 1.6.11 (r934486)
编译于 Mar 5 2014,14:28:03
版权所有 (C) 2000-2009 CollabNet。
Subversion 是开放源代码软件,请参阅 https://subversion.tigris.org/ 站点。
此产品包含由 CollabNet(https://www.Collab.Net/) 开发的软件。
下列版本库后端(FS) 模块可用:
* fs_base : 模块只能操作BDB版本库。
* fs_fs : 模块与文本文件(FSFS)版本库一起工作。
Cyrus SASL 认证可用。
— 查看Apache Webroot
[root@imagehost vhosts]# cat wordpress.conf
<DirectoryMatch "/alidata/www/wordpress/(attachment|html|data)">
<Files ~ ".php">
Order allow,deny
Deny from all
</Files>
</DirectoryMatch>
<VirtualHost *:80>
DocumentRoot /alidata/www/wordpress
ServerName localhost
ServerAlias localhost
<Directory "/alidata/www/wordpress">
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)-htm-(.*)$ .php?
RewriteRule ^(.*)/simple/([a-z0-9\_]+\.html)$ /simple/index.php?
</IfModule>
ErrorLog "/alidata/log/httpd/wordpress-error.log"
CustomLog "/alidata/log/httpd/wordpress.log" common
</VirtualHost>
–配置SVN仓库
[root@imagehost mnt]# mkdir -p ./svn/repos
[root@imagehost mnt]# svnadmin create /mnt/svn/repos
[root@imagehost mnt]# cd /mnt/svn/repos/
[root@imagehost repos]# ls
conf db format hooks locks README.txt
[root@imagehost repos]# cat README.txt
This is a Subversion repository; use the ‘svnadmin’ tool to examine
it. Do not add, delete, or modify files here unless you know how
to avoid corrupting the repository.
Visit https://subversion.tigris.org/ for more information.
–配置SVN内容
进入上面生成的文件夹conf下,进行配置, 有以下几个文件authz, passwd, svnserve.conf
其中authz 是权限控制,可以设置哪些用户可以访问哪些目录, passwd是设置用户和密码的, svnserve是设置svn相关的操作。
[root@imagehost /]# cd /mnt/svn/repos/
[root@imagehost repos]# ls
conf db format hooks locks README.txt
[root@imagehost repos]# cd conf/
[root@imagehost conf]# ls
authz passwd svnserve.conf
[root@imagehost conf]# vi passwd
设置用户密码
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
udast=udast*123~!abc
设置authr
[root@imagehost conf]# vi authz
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
### – a single user,
### – a group of users defined in a special [groups] section,
### – an alias defined in a special [aliases] section,
### – all authenticated users, using the ‘$authenticated’ token,
### – only anonymous users, using the ‘$anonymous’ token,
### – anyone, using the ‘*’ wildcard.
###
### A match can be inverted by prefixing the rule with ‘~’. Rules can
### grant read (‘r’) access, read-write (‘rw’) access, or no access
### (”).
[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
#设置对所有文件读写权限
[/]
udast=rw
配置环境
设定svnserve.conf
anon-access = none # 使非授权用户无法访问
auth-access = write # 使授权用户有写权限
password-db = password
authz-db = authz # 访问控制文件
realm = /opt/svn/repos # 认证命名空间,subversion会在认证提示里显示,并且作为凭证缓存的关键字。
采用默认配置. 以上语句都必须顶格写, 左侧不能留空格, 否则会出错.
如下,标红的需要顶格写。
[root@imagehost conf]# vi svnserve.conf
### Visit https://subversion.tigris.org/ for more information.
[general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
anon-access = read
auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file’s location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file’s location is relative to the the
### directory containing this file. If you don’t specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository’s uuid.
realm = /mnt/svn/repos
[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### This section will be ignored if svnserve is not built with Cyrus
### SASL support; to check, run ‘svnserve –version’ and look for a line
### reading ‘Cyrus SASL authentication is available.’
# use-sasl = true
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
启动SVN
[root@imagehost conf]# svnserve -d -r /mnt/svn/repos
[root@imagehost conf]# netstat -antp | grep svn
tcp 0 0 :::3690 :::* LISTEN 10019/svnserve
–待续
声明: 除非转自他站(如有侵权,请联系处理)外,本文采用 BY-NC-SA 协议进行授权 | 嗅谱网
转载请注明:转自《搭建SVN服务器与Apache同步》
本文地址:http://www.xiupu.net/archives-5063.html
关注公众号:
微信赞赏
支付宝赞赏