码迷,mamicode.com
首页 > Web开发 > 详细

centos 6.4安装svn+httpd

时间:2015-05-26 16:28:29      阅读:421      评论:0      收藏:0      [点我收藏+]

标签:centos 6.4安装svn+httpd

安装参考文档http://wiki.centos.org/HowTos/Subversion?highlight=%28subversion%29

一、环境

    系统:centos6.4x64最小化安装

    IP:192.168.3.73

二、安装

    配置epel源

[root@svn ~]# rpm  -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.soEIXi: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@svn ~]# sed -i ‘s@#baseurl@baseurl@‘ /etc/yum.repos.d/epel.repo
[root@svn ~]# sed -i ‘s@mirrorlist@#mirrorlist@‘ /etc/yum.repos.d/epel.repo

    同步时间

[root@svn ~]# yum install ntpdate -y
[root@svn ~]# ntpdate asia.pool.ntp.org
26 May 10:54:54 ntpdate[1490]: step time server 202.73.36.32 offset 142.398912 sec
[root@svn ~]# hwclock -w
[root@svn ~]# echo "*/10 * * * * /usr/sbin/ntpdate asia.pool.ntp.org &>/dev/null" >>/var/spool/cron/root

    安装相关软件包

[root@svn ~]# yum install httpd httpd-devel mod_dav_svn subversion mod_ssl -y

#查看安装后的结果
[root@svn ~]# ls /etc/httpd/modules/ |grep svn
mod_authz_svn.so
mod_dav_svn.so
[root@svn ~]# svn --version |grep version
svn, version 1.6.11 (r934486)

    到此svn的安装已完成

三、配置svn服务器

    创建一个用来存储svn文件

[root@svn ~]# mkdir -p /data/svn

#新建一个版本库
[root@svn /]# svnadmin create /data/svn
[root@svn data]# cd /data/svn/
[[root@svn svn]# ls /svn/
conf  db  format  hooks  locks  README.txt
[root@svn svn]# chown -R apache.apache /data/svn

    配置subversion.conf

[root@svn svn]# egrep -v "^#|^$"  /etc/httpd/conf.d/subversion.conf 
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
<Location /svn-test>
    DAV svn
    SVNPath /data/svn
    SVNListParentPath on
      AuthType Basic
      AuthName "svn server"
      AuthUserFile /data/passwdfile
      AuthzSVNAccessFile /data/accessfile
      Require valid-user
</Location>

    添加用户名和密码

[root@svn ~]# htpasswd -c /data/passwdfile weyee        #这里的-c选项是清楚所有
New password: 
Re-type new password:                                  #密码weyee2014
Adding password for user weyee
[root@svn ~]# htpasswd  /data/passwdfile ceshi          #添加另外的svn用户,密码weyee2014
New password: 
Re-type new password: 
Adding password for user test
[root@svn ~]# cat /svn/passwdfile 
weyee:uKp4.Z6yOTdac
test:ZDfPcwIOd1Gp2

#启动httpd服务
[root@svn ~]# /etc/init.d/httpd start
Starting httpd: httpd: apr_sockaddr_info_get() failed for svn
httpd: Could not reliably determine the server‘s fully qualified domain name, using 127.0.0.1 for ServerName
                                                           [  OK  ]
[root@svn ~]# netstat -anpt |grep httpd
tcp        0      0 :::80                       :::*                        LISTEN      23162/httpd         
tcp        0      0 :::443                      :::*                        LISTEN      23162/httpd

四、创建权限控制文件

[root@svn svn]# pwd
/data/svn
[root@svn svn]# ll
total 28
drwxr-xr-x 2 apache apache 4096 May 26 13:46 conf
drwxr-sr-x 6 apache apache 4096 May 26 13:46 db
-r--r--r-- 1 apache apache    2 May 26 13:46 format
drwxr-xr-x 2 apache apache 4096 May 26 13:46 hooks
drwxr-xr-x 2 apache apache 4096 May 26 13:46 locks
-rw-r--r-- 1 root   root     40 May 26 13:50 passwdfile
-rw-r--r-- 1 apache apache  229 May 26 13:46 README.txt
[root@svn svn]# cat accessfile 
[/]
*=rw

[groups]
dev=weyee
test=ceshi

[svn-test:/]
@test=r
@dev=rw

[repos:/test]
@test=rw
*=

    启动svn服务器

[root@svn svn]# svnserve -d -r /data
[root@svn svn]# netstat -anpt |grep svn
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      23337/svnserve      
[root@svn svn]# ps aux|grep svn |grep -v grep
root     23337  0.0  0.0 156908   748 ?        Ss   11:37   0:00 svnserve -d -r /data

    测试结果,使用weyee用户

技术分享

技术分享

技术分享

创建一个文件6.txt,并上传

技术分享

技术分享

    我们将weyee用户对svn-test的写权限去掉

[root@svn data]# cat accessfile 
[/]
*=r

[groups]
dev=weyee
test=ceshi

[svn-test:/]
@test=r
@dev=r

      重新创建一个7.txt,并提交

技术分享

    恢复写权限,继续提交

[root@svn data]# cat accessfile 
[/]
*=r

[groups]
dev=weyee
test=ceshi

[svn-test:/]
@test=r
@dev=rw

技术分享

技术分享


    怎么创建其他的代码库呢?

root@svn ~]# cd /tmp
[root@svn tmp]# mkdir mytestproj
[root@svn tmp]# cd mytestproj
[root@svn mytestproj]# mkdir configurations options main
[root@svn mytestproj]# vim configurations/testconf1.cfg
[root@svn mytestproj]# vim options/testopts1.cfg
[root@svn mytestproj]# vim main/mainfile1.cfg
[root@svn mytestproj]# svn import /tmp/mytestproj/ file:///data/svn/mytestproj -m "initial repos in mytestproj"
Adding         /tmp/mytestproj/main
Adding         /tmp/mytestproj/main/mainfile1.cfg
Adding         /tmp/mytestproj/configurations
Adding         /tmp/mytestproj/configurations/testconf1.cfg
Adding         /tmp/mytestproj/options
Adding         /tmp/mytestproj/options/testopts1.cfg

Committed revision 9.
#检出刚才创建的代码库
[root@svn ~]# svn co http://192.168.3.73/svn-test/mytestproj
Authentication realm: <http://192.168.3.73:80> svn server
Password for ‘root‘: 
Authentication realm: <http://192.168.3.73:80> svn server
Username: weyee
Password for ‘weyee‘: 

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <http://192.168.3.73:80> svn server

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the ‘store-plaintext-passwords‘ option to either ‘yes‘ or ‘no‘ in
‘/root/.subversion/servers‘.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes
A    mytestproj/main
A    mytestproj/main/mainfile1.cfg
A    mytestproj/configurations
A    mytestproj/configurations/testconf1.cfg
A    mytestproj/options
A    mytestproj/options/testopts1.cfg
Checked out revision 9.

    权限控制

[root@svn data]# pwd
/data
[root@svn data]# cat accessfile
[/]
*=r

[groups]
dev=weyee
test=ceshi

[svn-test:/]
@test=r
@dev=r

[svn-test:/mytestproj]
@dev=r
@test=rw

    从权限上看,应该是weyee对mytestproj只有读取权限,ceshi有读写权限

    测试,新建一个qq.txt使用weyee账号提交

技术分享

技术分享

技术分享

    现在我们更换用户提交使用ceshi 

技术分享

技术分享


    到此基于httpd的svn基本是完成了

    更多的请参考http://kaibinyuan.blog.51cto.com/7304008/1609488

本文出自 “ly36843运维” 博客,请务必保留此出处http://ly36843.blog.51cto.com/3120113/1655187

centos 6.4安装svn+httpd

标签:centos 6.4安装svn+httpd

原文地址:http://ly36843.blog.51cto.com/3120113/1655187

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!