지니워
2014. 12. 15. 22:18
예전 회사에서 개발자들이
"svn 설치해주세요~"
라는 말을 자주 했었다. 그때 당시에는 svn이 뭔지도 모르는 상태여서 레퍼런스를 찾아서 설치만 해주었는데 최근에 다시 svn에 대하여 알아볼 기회가 되어서 아래와 같이 svn설치 및 apache와 연동하는 방법에 대하여 알아보았다. 출처는http://blog.beany.co.kr/archives/240.
기본 설치시에는 1.4.1 버전이며, 최신 버전으로 설치시에는 respository 를 변경해서 설치를 진행해야 합니다.
| rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm |
yum 으로 webtatic 저장소에 접속하여 svn 과 apache 연동 모듈을 설치합니다.
| yum install --enablerepo=webtatic subversion mod_dav_svn |
SVN Repository Root 디렉토리를 생성합니다.
| mkdir /data/repository/svn/repo |
SVN Repository 를 생성합니다.
| svnadmin create /data/repository/svn/repo/devsample |
Apache Httpd Server 와 연동
yum 으로 설치한 mod_dav_svn httpd server 연동 파일은 /usr/lib64/httpd/modules 에 위치하고 있으며, 해당 파일을 /modules 디렉토리에 복사합니다.
| cd /usr/lib64/httpd/modules cp mod_dav_svn.so mod_authz_svn.so /opt/httpd-2.2.17/modules |
/conf/extra 에서 아래의 파일을 vi 편집기로 생성합니다.
아래와 같이 SVN 연동 설정을 합니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ############################################################## # SVN ############################################################## LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so <VirtualHost *:80> ServerName svn.beany.co.kr ServerAlias svn.beany.co.kr DocumentRoot "/data/webapps/svn/public_html" ServerAdmin admin@beany.co.kr SetEnvIf Request_URI "\.(gif)|(jpg)|(swf)|(png)$" image_log CustomLog "logs/svn_access_log.log" common env=!image_log CustomLog "logs/svn_access_image_log.log" common env=image_log ErrorLog "logs/svn_error_log.log" <Location /devsample> DAV svn SVNPath "/data/repository/svn/repo/devsample" # SVNParentPath "/data/repository/svn/devsample" # SVNListParentPath On SVNIndexXSLT "/repos-web/view/repos.xsl" AuthType Basic AuthName "Beany SVN Repository" AuthUserFile "/data/repository/svn/authz/passwd" AuthzSVNAccessFile "/data/repository/svn/authz/authz" Require valid-user </Location> </VirtualHost> <Directory "/data/webapps/svn/public_html"> Options FollowSymLinks MultiViews AllowOverride None Order deny,allow Deny from all Allow from all </Directory> |
SVNIndexXSLT 항목은 SVN 을 브라우저로 접근시 보이는 화면의 스타일을 설정해주는 항목이며, 관련 파일은http://reposstyle.com/#download 에서 다운로드 받을 수 있습니다.
해당 파일을 다운로드 받아 DocumentRoot 로 설정한 디렉토리에 압축을 해제하시면 됩니다.
/conf 의 httpd.conf 파일을 vi 편집기로 엽니다.
httpd.conf 에 위에서 설정한 httpd-vhosts-svn.conf 파일의 경로를 추가하여 줍니다.
| ### svn.beany.co.kr Virtual hosts Include conf/extra/httpd-vhosts-svn.conf |
사용자 계정 추가
최초 사용자 설정시 /data/repository/svn/authz/passwd 파일이 존재하지 않을 경우에는 /bin/htpasswd 명령어에 -c 옵션을 설정하여 사용자를 생성합니다.
passwd 파일이 생성된 후 -c 옵션을 줄 경우에는 새로 파일을 만들기 때문에 기존에 생성된 사용자가 전부 삭제되고, 현재 등록하는 사용자만 남게 됩니다.
| ./htpasswd -c /data/repository/svn/authz/passwd <UserID> |
| ./htpasswd /data/repository/svn/authz/passwd <UserID> |
권한 설정
/data/repository/svn/authz/authz 파일에 해당 사용자의 권한을 부여합니다.
- groups : 사용자 그룹을 설정하며, 사용자 ID 는 comma (,) 로 구분합니다.
- respository 항목에서 그룹명은 ‘@’ 을 붙여 설정하며, 일반 사용자는 아이디를 직접 명시를 하시면 됩니다. 옵션은 r (read) w (write) 가 있습니다.
| [groups] admin = <UserID>, <UserID> [devsample:/] @admin = rw |
실행확인
httpd server 를 재시작한 후 http://IP/devsample 에 접속하여 정상적으로 인증 및 SVN 저장소 디렉토리가 출력되는지 확인합니다.