注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

phperwuhan的博客

记载一个phper的历程!phperwuhan.blog.163.com

 
 
 

日志

 
 

安装subversion https server  

2011-03-05 17:27:07|  分类: svn |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

来源:http://bbs3.chinaunix.net/redirect.php?tid=1333550&goto=lastpost

一: 安装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.

  评论这张
 
阅读(897)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017