免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4595 | 回复: 1
打印 上一主题 下一主题

安装subversion https server, 并实现版本库的同步 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-14 00:01 |只看该作者 |倒序浏览
一: 安装subversion https server

1. Install Apache
In the terminal type:

sudo apt-get install apache2 apache2.2-common apache2-utils

               
This installs the apache 2 server common modules and utilities
2. Install Subversion
In the terminal type:

sudo apt-get install subversion subversion-tools

               
3. Install Apache Subversion Modules
In the terminal :

sudo apt-get install libapache2-svn

               
4. Restart Apache
In the terminal type:

sudo apache2ctl restart

               
5. Enable SSL Apache Module
In the terminal type:

sudo a2enmod ssl

               
6. Enable Apache to listen to the correct port for ssl (443)
In the terminal type:

sudo gedit /etc/apache2/ports.conf

               
Add the line: Listen 443
Note: Actually we can ignore this step, Because port 443 is enabled by default in /etc/apache2/site-*/default. If your apache fails to start after subversion virtual host configuration, please comment port 443 line in ports.conf.
7. Create a certificate for SSL use.
Unfortunately apache is missing the tool (apache2-ssl-certificate) required to create the certificate but this can be easily downloaded from apache2-ssl.tar.gz , download this file and extract the package. There are two files ssleay.cnf and apache2-ssl-certificate. In the terminal navigate to the directory two files have been extracted and type:
sudo mkdir /etc/apache2/ssl
sudo cp ./ssleany.cnf  /etc/apache2/ssl/
sudo cp ./apache2-ssl-certificate /usr/sbin/

Now create your certificate with and follow the instructions

sudo apache2-ssl-certificate

Note: Ubuntu Feisty/Debian has a bug where the command apache2-ssl-certificate is missing. This is a well documented bug. Here is the file you need to download to overcome this defect to create a self signed certificate. After you download, follow the notes below to copy the downloaded files to the location where they are supposed to be present.
1.        Extract the package
2.        put ssleay.cnf to /usr/share/apache2/
3.        put apache2-ssl-certificate to /usr/sbin.
4.        Create /etc/apache2/ssl directory.
Now apache2-ssl-certificate script should work. Please follow this link if you want to know how to use it.
8. Create a Subversion repository

Here make a directory where you want to store one or more subversion repositories, in this example I’m using /srv/svn/repos/

sudo mkdir  /srv
sudo mkdir  /srv/svn
sudo mkdir  /srv/svn/repos

               
Now make the repository directory accessible to apache (www-data)

chown www-data:www-data /srv/svn/repos

               
Now we will make the first repository using the super user www-data

cd /srv/svn/repos
su -u www-data -s
svnadmin create projectname
We now have our first subversion repository remember when creating other repositories always use the su www-data to ensure apache can access the repository.
9. Creating the virtual host

Create the virtul host file for Apache

sudo cp /etc/apache2/sites-available/default  /etc/apache2/sites-available/svn.domain.com
sudo gedit  /etc/apache2/sites-available/svn.domain.com
Copy and paste the following code edit the domain name and repository path if different:

NameVirtualHost *:443
<VirtualHost *:443>
  ServerAdmin yourname@domain.com
  ServerName svn.domain.com
  SSLEngine On
  SSLCertificateFile /etc/apache2/ssl/apache.pem
  SSLProtocol all
  SSLCipherSuite HIGH:MEDIUM
  <Location />
    Order allow,deny
    Allow from all
    DAV svn
    SVNPath /srv/svn/repos/projectname
    AuthType Basic
    AuthName "domain.com Subversion Repository"
    AuthUserFile /etc/apache2/dav_svn.passwd
    Require valid-user
  </Location>
  ErrorLog /var/log/apache2/error.log

  # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
  LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>

               
If you have many projects that you will be using the repository change

SVNPath /srv/svn/repos/project

to

SVNParentPath /srv/svn/repos

10. Create user(s) to access subversion repository

sudo htpasswd -c /etc/apache2/dav_svn.passwd username

to add more users use -m (the -c creates a new file)

sudo htpasswd -m /etc/apache2/dav_svn.passwd username2

11. Restart Apache and test

sudo /etc/init.d/apache2 restart

Now test your repostory with https://svn.domain.com and enjoy, if I’ve missed steps out please let me know in the comments.

二: 装镜像服务器,安装方法同上,别忘了改apache虚拟主机配置中指向镜像版本库的路径。


三:在镜像服务器上设置同步

Introduction
You may need to backup your svn repos so that data is safe even if something happens to the main repos.There are many ways of doing it I did it using svnsync.
So this is what we will do.
•        We will create a mirror repo in some other system.
•        svnsync will synchronize the mirror repo with the main repo
•        and we set the hooks that no one else other than the synsync changes the mirror repo.
Create a mirror repo
Mirror repo is just another svn repo created by svnadmin create command
svnadmin create /var/svnmirror
Create a svn user
We create an svn user such that only that user can change the mirror repo. We can add user by editing svnserv.conf and the password file
on file /conf/svnserve.conf uncomment the following line
# Uncomment this line.
password-db = passwd
on file /conf/passwd add this code
syncuser = mypasswd

on file /conf/authz
[/]
* = r
svnsync = rw

Add the hooks
We need to add pre-revprop-change hook and start-commit hook so that only svnsync modifies the svn-mirror
Add the following code to file /hooks/pre-revprop-change
#!/bin/sh
USER="$3"
if [ "$USER" = "syncuser" ]; then exit 0; fi
echo "Only the syncuser user can change revprops" >&2
exit 1
Make the file executable
chmod +x /hooks/pre-revprop-change

Add the following code to file /hooks/start-commit
#!/bin/sh
USER="$2"
if [ "$USER" = "syncuser" ]; then exit 0; fi
echo "Only the syncuser user may commit new revisions" >&2
exit 1
Make the file executable
chmod +x /hooks/start-commit

Synchronize with the main repo
For synchronizing with the main repo first we initialize the svn sync by this resisters which all repos has to be synchronised with which all source repos
svnsync init <mirror> <source>
eg:
svnsync init file:///var/svnmirror http://www.iiitmk.ac.in/svn/projects/my-project
Next we do a synchronisation by the command
svnsync sync <mirror repo's url>
eq:svnsync sync file:///var/svnmirror

Cache certificate to www-data home folder:

Cp –rf /root/.subversion/ /var/www  #www-data home folder.
Cd /var/www
Chown –R www-data.www-data .subversion  
Registering it in the cron job
You can add svn sync to the cron job's so that it does it daily without any user intervention.
on the command line give the command
crontab -e
this will open an editor add this line to it
30 1 * * *  svnsync sync file:///var/svnmirror
So that the mirror gets synchronized at 1:30 daily.

论坛徽章:
0
2 [报告]
发表于 2008-12-14 20:37 |只看该作者

回复 #1 carrison 的帖子

很好的,现在使用svn的要对于cvs的,google的code就是使用svn
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP