找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 服务器 Linux/BSD 查看内容

svn和apache从安装到配置

2009-12-20 13:28| 发布者: admin| 查看: 25| 评论: 0|原作者: 云天青


v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}

Normal
0
false


7.8 磅
0
2

false
false
false

EN-US
ZH-CN
X-NONE












































































































































































/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:105%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Cambria","serif";
mso-ascii-font-family:Cambria;
mso-ascii-theme-font:major-latin;
mso-hansi-font-family:Cambria;
mso-hansi-theme-font:major-latin;
mso-fareast-language:EN-US;
mso-bidi-language:EN-US;}
table.MsoTableGrid
{mso-style-name:网格型;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-priority:59;
mso-style-unhide:no;
border:solid black 1.0pt;
mso-border-themecolor:text1;
mso-border-alt:solid black .5pt;
mso-border-themecolor:text1;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-border-insideh:.5pt solid black;
mso-border-insideh-themecolor:text1;
mso-border-insidev:.5pt solid black;
mso-border-insidev-themecolor:text1;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Cambria","serif";
mso-ascii-font-family:Cambria;
mso-ascii-theme-font:major-latin;
mso-hansi-font-family:Cambria;
mso-hansi-theme-font:major-latin;
mso-fareast-language:EN-US;
mso-bidi-language:EN-US;}
SVN和Apache从安装到配置
Part 1: 平台搭建篇
一、安装apache
1.
http://httpd.apache.org/
Download httpd-2.2.9.tar.bz2
2.
#./configure --enable-dav --enable-so --prefix=/usr/local/apache
3.
#make
4.
#make install
5.
拷贝源码包module里面的所有到 /usr/local/apache/module里面, 如果已经有了就不用拷了,不然的话编译Subversion会通不过
6.
修改配置文件,开启ServerName 192.168.1.235:80
7.
启动#/usr/local/apache/bin/apachectl
-k start
8.
在浏览器输入地址
http://192.168.1.235
看能否访问,地址应为你的服务器地址。如果浏览器出现It works. 说明apache安装成功
二、安装Subversion
1.
安装前的准备(Prerequisite)
You'll need the
following build tools to compile Subversion:
*
autoconf 2.58 or later (Unix only)
*
libtool 1.4 or later (Unix only)
*
a reasonable C compiler (gcc, Visual Studio, etc.)
1)
libz (REQUIRED for client and
server) 大多数机器已经有了
2)
安装libapr 和 libapr-util
* libapr and
libapr-util (REQUIRED for client and server)
A.Go to
http://apr.apache.org/
to download the lastest version
of apr and apr-util.
apr-1.3.2.tar.bz2
apr-util-1.3.2.tar.bz2
B. 解压缩
#tar
jxvf apr*.bz2 每个文件单独解压
C. 编译安装
#./configure -–prefix=/usr/local/apr //for apr

#./configure
--prefix=/usr/local/apr –with-apr=/usr/local/apr
//for apr-util
#make
#make install
3)
安装expat (XML Parser)
http://expat.sourceforge.net/
Download expat-2.0.1.tar.gz
#./configure
#make
#make
install
4)
安装libneon (for http://)
http://www.webdav.org/neon/
Download neon-0.28.2.tar.gz
#./configure --prefix=/usr/local/neon
#make
#make install
5)
安装openssl (for https://)
http://www.openssl.org/source/
Download openssl-0.9.8h.tar.gz
#./configure --prefix=/usr/local/openssl
#make
#make install
6)
Berkeley DB (OPTIONAL for client and server) 这个我没装,可选
There are two
different repository 'back-end'implementations.
One implementation stores data in a flat filesystem (known as FSFS); the
other implementation stores data in a Berkeley DB database (known as BDB). When you create a repository, you have the
option of specifying a storage back-end.
The Berkeley DB back-end will only be available if the BDB libraries are
discovered at compile time.
2.
安装Subversion
1)
http://subversion.tigris.org/
Download subversion-1.5.1.tar.bz2
2)
解压#tar jxvf subversion-1.5.1.tar.bz2
3)
进入解压后的目录
#./configure
--prefix=/usr/local/svn --with-apr=/usr/local/apr
--with-apr-util=/usr/local/apr --with-apxs=/usr/local/apache/bin/apxs
--with-neon=/usr/local/neon
#make
#make install
4)
运行#/usr/local/svn --version看是否安装成功,至少应具备以下几个模块:
The following
repository access (RA) modules are available:
* ra_neon : Module
for accessing a repository via WebDAV protocol using Neon.
- handles 'http' scheme
* ra_svn : Module for
accessing a repository using the svn network protocol.
- handles 'svn' scheme
* ra_local : Module
for accessing a repository on local disk.

- handles 'file' scheme
Part 2: 环境配置篇
1.
配置svn主目录
#mkdir /home/svn
2.
创建主版本库
#svnadmin create
/home/svn
此时会在/home/svn里面生成以下文件和文件夹:
conf
db
format hooks locks README.txt
3.
可以创建多个子版本库,对应不同的project
#svnadmin create /home/svn/project1
#svnadmin create /home/svn/project2
……
4.
停止apache
#/usr/local/apache/bin/apachectl stop
5.
编辑httpd.conf
LoadModule
dav_svn_module modules/mod_dav_svn.so
LoadModule
authz_svn_module
modules/mod_authz_svn.so

a.
如果svn只有一个主版本
DAV
svn
SVNPath /home/svn
b.
如果svn有多个版本库
DAV
svn
SVNParentPath /home/svn
6.
重启apache服务器
#/usr/local/apache/bin/apachectl start
7.
在浏览器输入
对应于只有一个版本库的如下访问:
http://192.168.1.235/svn
即可
但对于多个版本库的需指明具体到哪个版本库的路径:
http://192.168.1.235/svn/project1
http://192.168.1.235/svn/project2
……
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/moz-screenshot.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://blogimg.chinaunix.net/blog/upfile2/080919173828.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
Figure 1: Project ppcdn2.0 view
8.
Import 和checkout
A)设置树形目录
/tmp/project/ppcdn2.0/branch
/tmp/project/ppcdn2.0/tags
/tmp/project/ppcdn2.0/trunk
Foo.c
Test.c
Makefile
即把你欲上传的源文件都拷贝到trunk目录下
然后运行以下命令上传
#svn import /tmp/project/ file:///home/svn -m "initial import"这个命令的意思是把project 目录下的全部东西按原目录层次上传。这样就可以通过
http://192.168.1.235/svn
直接访问树形目录倘若还有ppcdn3.0,多个项目我就可以方便的点击树形目录如果分别为ppcdn2.0和ppcdn3.0建立单独的版本库,则每次需要输入完整路径才能访问。这个地方折腾了我很久,我一开始是建立的多个版本库,每次访问都很麻烦。所以如果想省力访问的话,最好只建一个版本库!B)签出#svn checkout file:///home/svn/ppcdn2.0 /home/gxl/ppcdn2.0C)你现在在project目录里有了一个版本库的个人拷贝,你可以编辑你的工作备份中的文件,并且提交到版本库。 * 进入到你的工作备份,编辑一个文件的内容。* 运行svn diff来查看你的修改的标准区别输出。* 运行svn commit来提交你的改变到版本库。* 运行svn update将你的工作拷贝与版本库“同步”。
9.
设置权限认证(详细设置见
http://www.subversion.org.cn/svnbook/1.1/index.html

第6章)
1)
基本HTTP认证
最简单的客户端认证方式是通过HTTP基本认证机制,简单的使用用户名和密码来验证一个用户所自称的身份,Apache提供了一个htpasswd工具来管理可接受的用户名和密码,这些就是你希望赋予Subversion特别权限的用户,让我们给Sally和Harry赋予提交权限,首先,我们需要添加他们到密码文件。
为了简便,建议把/usr/local/apache/bin/目录下的文件在/usr/bin下面建立符号链接#ln –s
/usr/local/apache/bin/htpasswd /usr/bin/htpasswd


$ ### First time:
use -c to create the file
$ ### Use -m to
use MD5 encryption of the password, which is more secure
$ htpasswd -cm /etc/subversion/passwd harry
New password: *****
Re-type new password: *****
Adding password for user harry
$ htpasswd -m /etc/subversion/passwd sally //注意跟上面的命令有区别
New password: *******
Re-type new password: *******
Adding password for user sally



下一步,你需要在httpd.conf的Location区里添加一些指示来告诉Apache如何来使用这些密码文件,AuthType指示指定系统使用的认证类型,这种情况下,我们需要指定Basic认证系统,AuthName是你提供给认证域一个任意名称,大多数浏览器会在向用户询问名称和密码的弹出窗口里显示这个名称,最终,使用AuthUserFile指示来指定使用htpasswd创建的密码文件的位置。

添加完这三个指示,你的区块一定像这个样子:



DAV svn

SVNParentPath /home/svn

AuthType Basic

AuthName "Subversion repository"
AuthUserFile /etc/subversion/passwd




这个区块还没有结束,还不能做任何有用的事情,它只是告诉Apache当需要授权时,要去向Subversion客户端索要用户名和密码。我们这里遗漏的,是一些告诉Apache什么样客户端需要授权的指示。哪里需要授权,Apache就会在哪里要求认证,最简单的方式是保护所有的请求,添加Require valid-user来告诉Apache任何请求需要认证的用户:




DAV svn

SVNParentPath /home/svn

AuthType Basic

AuthName "Subversion repository"
AuthUserFile /etc/subversion/passwd

Require valid-user



需要警惕:HTTP基本认证的密码是用明文传输,因此非常不可靠的,如果你担心密码偷窥,最好是使用某种SSL加密,所以客户端认证使用https://而不是http://,为了方便,你可以配置Apache为自签名认证。







最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 07:17 , Processed in 0.140149 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部