文章轉自https://www.cnblogs.com/ayanmw/archive/2011/12/19/2294054.html
你看到的這個文章來自於http://www.cnblogs.com/ayanmw
基本的安裝包有: subversion /httpd/ svn的httpd的mod_dav_svn mod_authz_svn 兩個模塊.(yum install mod_dav_svn subversion httpd )
svn的服務形式應該是有兩種: 1 通過svnserve建立的 通過svn://ip:port 端口默認是3690,這種形式; 2 通過apache httpd或者其他的web服務器的擴展模塊,進行svn管理
對於svnserve,通過svnserve -d -r /var/www/svn 這種形式建立 daemon的后台進程,但是結束要 kill `pgrep svnserve` 這種形式 來kill掉,不知道有沒有直接的比如 stop的方式.
通過http服務器來管理svn也很不錯,可以很方便的瀏覽.其配置過程如下(首先幾個軟件都安裝,這就不用說了.):
1.在 /etc/httpd/module下面 有兩個 mod 關於 svn的.
2.在/etc/httpd/config.d/下有一個subversion.conf(沒有就建立一個),其內容是:
LoadModule dav_module modules/mod_dav.so
LoadModule dav_svn_module modules/mod_dav_svn.so
<Location /svn>
DAV svn
SVNPath /var/www/svn/
AuthType Basic
AuthName "Subversion repos"
AuthUserFile /var/www/svn/repos1/conf/passwd
Require valid-user
</Location>
# To create a new repository "http://localhost/repos/stuff" using
# this configuration, run as root:
#
# # cd /var/www/svn
# # svnadmin create stuff
# # chown -R apache.apache stuff
# # chcon -R -t httpd_sys_content_t stuff
#<Location /repos>
# DAV svn
# SVNParentPath /var/www/svn
#
# # Limit write permission to list of valid users.
# <LimitExcept GET PROPFIND OPTIONS REPORT>
# # Require SSL connection for password protection.
# # SSLRequireSSL
#
# AuthType Basic
# AuthName "Authorization Realm"
# AuthUserFile /path/to/passwdfile
# Require valid-user
# </LimitExcept>
#</Location>
其中/var/www/svn是准備放倉庫的目錄,這個目錄可以放置多個代碼倉庫,AuthUserFile就是用戶和密碼的文件,也可以移動到其他地方單獨管理.
/var/www/svn 下面可以通過 svnadmin createa /var/www/svn/repos1 來建立一個空的倉庫.還可以建立多個倉庫;這個目錄貌似最好 給apche用戶所有權限:chown -R apache.apache /var/www/svn ;在repos1/conf目錄下可以進行一些賬號密碼 配置,就不多說了.建立的其他倉庫 可以拷貝這些conf文件
其中AuthUserFile 是如何制作的呢?
創建“ AuthUserFile ”設置所需的用戶密碼以及存儲的文件 使用 apache bin/htpasswd 命令來創建。命令的格式為 htpasswd [-cmdpsD] passwordfile username 若第一次創建用戶,我們必須使用參數“-c”來同時創建用戶密碼文件 htpasswd -c passwd robert 上述命令創建的一個文件“ passwd”,同時在文件里添加了一個 user named “robert”,執行該命令時會要求輸入密碼。 注意:創建第二或之后的用戶時,一定不能用參數“ c ”,否則之前的用戶就會被刪除。 如果想要刪除某個用戶,我們可以使用下列命令: htpasswd -D passwd robert 這樣, robert就被從 passwd中刪除了。
下面就是一個示例,創建兩個用戶 a b,密碼 aaa,bbb,再刪除。查看密碼文件內容:
[root@src-server websvn]# htpasswd accesspwd a htpasswd: cannot modify file accesspwd; use '-c' to create it [root@src-server websvn]# htpasswd -c accesspwd a New password: Re-type new password: Adding password for user a [root@src-server websvn]# ll accesspwd -rw-r--r-- 1 root root 16 Jun 23 02:03 accesspwd [root@src-server websvn]# htpasswd accesspwd b New password: Re-type new password: Adding password for user b [root@src-server websvn]# cat accesspwd a:wpEqdKjINQsvM b:JEpHUbhZZP3fc [root@src-server websvn]# htpasswd -D accesspwd b Deleting password for user b [root@src-server websvn]# cat accesspwd a:wpEqdKjINQsvM [root@src-server websvn]#
3. sudo service httpd restart 重啟httpd apache 服務. 貌似很簡單呢..回來再整理下svn的命令 補充.
然后通過 http://IP/svn/repos1可以訪問這個倉庫,可以建立多個倉庫同時訪問.不過直接訪問 IP/svn 無法列出倉庫的列表,apache顯示 "forbidden \n You don't have permission to access /svn on this server"
對於一些svn的web管理程序也有,比如ViewVC 還有一些其他的管理svn的web程序,最好可以在web端創建倉庫、權限管理就好了。目前尋找這樣的svn web管理程序中。
CentOS 安裝websvn直接yum即可,不需要配置mysql,只需要php的支持即可。
查看websvn的包文件
[root@src-server ~]# yum install websvn Loaded plugins: fastestmirror, presto, refresh-packagekit Loading mirror speeds from cached hostfile * base: mirrors.btte.net * epel: ftp.kddilabs.jp * extras: ftp.stu.edu.tw * kernel-xen: us1.mirror.crc.id.au * updates: mirrors.tuna.tsinghua.edu.cn Setting up Install Process Package websvn-2.3.3-2.el6.noarch already installed and latest version Nothing to do [root@src-server ~]#rpm -ql websvn /etc/httpd/conf.d/websvn.conf /etc/websvn/config.php /usr/share/doc/websvn-2.3.3 /usr/share/doc/websvn-2.3.3/changes.txt /usr/share/doc/websvn-2.3.3/doc /usr/share/doc/websvn-2.3.3/doc/install.html /usr/share/doc/websvn-2.3.3/doc/style.css /usr/share/doc/websvn-2.3.3/doc/templates.html /usr/share/doc/websvn-2.3.3/license.txt /usr/share/websvn /usr/share/websvn/blame.php /usr/share/websvn/cache /usr/share/websvn/comp.php /usr/share/websvn/diff.php /usr/share/websvn/dl.php /usr/share/websvn/filedetails.php /usr/share/websvn/include /usr/share/websvn/include/accessfile.php /usr/share/websvn/include/auth.php /usr/share/websvn/include/bugtraq.php /usr/share/websvn/include/command.php /usr/share/websvn/include/config.php /usr/share/websvn/include/configclass.php /usr/share/websvn/include/diff_inc.php /usr/share/websvn/include/diff_util.php /usr/share/websvn/include/header /usr/share/websvn/include/setup.php /usr/share/websvn/include/svnlook.php /usr/share/websvn/include/template.php /usr/share/websvn/include/utils.php /usr/share/websvn/include/version.php /usr/share/websvn/index.php /usr/share/websvn/languages /usr/share/websvn/languages/chinese-simplified.php /usr/share/websvn/languages/languages.php /usr/share/websvn/languages/省略省略省略 /usr/share/websvn/listing.php /usr/share/websvn/log.php /usr/share/websvn/revision.php /usr/share/websvn/rss.php /usr/share/websvn/temp /usr/share/websvn/templates /usr/share/websvn/templates/BlueGrey /usr/share/websvn/templates/BlueGrey/省略省略省略 /usr/share/websvn/templates/Elegant /usr/share/websvn/templates/Elegant/省略省略省略 /usr/share/websvn/templates/calm /usr/share/websvn/templates/calm/省略省略省略 /usr/share/websvn/wsvn.php /var/cache/websvn
下面就是vim /etc/websvn/config.php,其實這個文件就是/usr/share/websvn/include/config.php,只是做了一個鏈接到etc目錄,這種方法對於這種需要配置的web程序來說,還真是方便。
[root@src-server ~]# ll /etc/websvn/config.php -rw-r--r-- 1 root root 21210 Jun 24 18:48 /etc/websvn/config.php [root@src-server ~]# ll /usr/share/websvn/include/config.php lrwxrwxrwx 1 root root 33 Jun 23 01:01 /usr/share/websvn/include/config.php -> ../../../../etc/websvn/config.php [root@src-server ~]#
這里需要修改的配置選項有:
$config->parentPath('/srv/svn/');
$config->useMultiViews();
############ $config->useAuthenticationFile('/srv/svn/passwd');#這里是因為我 不知道如何在websvn上登錄我的賬號
$config->setBlockRobots();#防止搜索程序收錄
$config->expandTabsBy(4);#默認的8 似乎並不適合我的習慣
$config->useEnscript();##語法高亮 建議安裝GNU Enscript高亮顯示程序包,官方下載:http://www.iki.fi/~mtr/genscript/
# 關於編碼 我不知道如何設置,SetInputEncoding 對於我的websvn-2.3.3不起作用,反而websvn出現500錯誤。
修改/etc/httpd/conf.d/websvn.conf 添加基本權限認證
Alias /websvn /usr/share/websvn/ <Directory /usr/share/websvn/> Options MultiViews Indexes DirectoryIndex wsvn.php order allow,deny allow from all AuthType Basic AuthName "Authorization Realm" AuthUserFile /srv/svn/passwd Require valid-user </Directory>
websvn就可以在線瀏覽了。
第三節:在線修改htpasswd密碼
前面是由apache的htpasswd來通過 base 認證來進行賬號管理的。通過這個小程序可以在線添加刪除 校驗賬號密碼。還有點小遺憾是 沒有對 添加 刪除 進行權限管理。校驗后 才可以進行這個選項。
http://www.cnblogs.com/mutuan/archive/2012/07/27/2611537.html
參考:http://www.scmbbs.com/cn/svntp/2007/11/svntp1.php
轉載請注明出處:http://www.cnblogs.com/ayanmw 我會很高興的!
------------------------------------------------------------------------------------------------
一定要專業!本博客定位於 ,C語言,C++語言,Java語言,Android開發和少量的Web開發,之前是做Web開發的,其實就是ASP維護,發現EasyASP這個好框架,對前端后端數據庫 都很感覺親切啊。. linux,總之后台開發多一點。以后也願意學習 cocos2d-x 游戲客戶端的開發。