Subversion Server
Installing and Configuring subversion-server and apache2 with LDAP authentication
Subversion (SVN) คือระบบควบคุมการเปลื่ยนแปลงของไฟล์ เช่น เวอร์ชั่นของไฟล์ ทำให้ผู้ใช้งานสามารถพัฒนาโปรแกรมได้อย่างสะดวก (ของหวานโปรแกรมเมอร์เลยก็ว่าได้) อีกอย่างเป็นระบบ open source ด้วย.
ทดสอบบน Operating System: openSUSE 11.1
IP Address: 192.168.1.37
1). ติดตั้ง Apache2 และ subversion-serves:
ซอฟต์แวร์ที่ต้องติดต้อง สามารถติดจาก YaST ได้เลย
apache2 apache2-doc apache2-mod_security2 subversion-server
2). สร้างผู้ใช้และกลุ่มผู้ใช้สำหรับใช้งาน svn:
$ groupadd -r svn; useradd -r -g svn -d /srv/svn -s /bin/false svn
3). คอนฟิก apache2 และ subversion:
enable apache2 modules
$ a2enmod dav
$ a2enmod dav_svn
$ a2enmod ldap
$ a2enmod authnz_ldap
4). คอนฟิก subversion server authentication LDAP
$ vi /etc/apache2/conf.d/subversion.conf
# หรือจะ uncomment ออกแล้วแก้ไข path ก็ได้ถ้าไม่ต้องการ authentication
<IfModule mod_dav_svn.c>
##Added by Sontaya
<Location /repos>
# Enable Subversion
DAV svn
# Directory containing all repository for this path
SVNParentPath /srv/svn/repos/
SVNListParentPath on
# Require SSL connection for password protection.
<LimitExcept GET PROPFIND OPTIONS REPORT>
SSLRequireSSL
AuthBasicProvider ldap
# Do basic password authentication in the clear
AuthType Basic
# The name of the protected area or "realm"
AuthName "SVN repository LDAP Authorization Realm"
AuthLDAPURL ldap://192.168.1.11:389/dc=company?uid??(objectclass=*)
# The LDAP query URL
# Format: scheme://host:port/basedn?attribute?scope?filter
# The URL below will search for all objects recursively below the basedn
# and validate against the sAMAccountName attribute
# LDAP Authentication & Authorization is final; do not check other databases
AuthzLDAPAuthoritative on
# Active Directory requires an authenticating DN to access records
# This is the DN used to bind to the directory service
# This is an Active Directory user account
AuthLDAPBindDN cn=Administrator,dc=company
# This is the password for the AuthLDAPBindDN user in Active Directory
AuthLDAPBindPassword ******
# Require authentication for this Location
require valid-user
</LimitExcept>
</Location>
5). สร้าง Directory สำหรับ Supversion (subversion repository)
$ mkdir -p /srv/svn/repos
Restart apache2
$ rcapache2 restart
6). สร้าง Projects
$ svnadmin create /srv/svn/repos/myprojects
เปลื่ยนเจ้าของไฟล์
$ chown -R wwwrun:www /srv/svn/repos/myprojects
7). Enable https สำหรับ apache2 (ออปชั่นเพิ่มเติม)
สร้าง Certificate สามารถสร้างได้ 2 วิธี
1. script
$ gensslcert
$ cp /etc/apache2/vhosts.d/vhost-ssl.template /etc/apache2/vhosts.d/vhost-ssl.conf
$ vi /etc/apache2/vhosts.d/vhost-ssl.conf (ตรวจสอบ ถ้าต้องการแก้ไข)
2. manual
อ่านจากลิงค์ข้างล่างน
http://www.susethailand.com/index.php/en/apache2-secure-sockets-layer
8). Restart apache2 (SSL)
$ rcapache2 restart -DSSL (start ssl)
Error: Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration
แก้ไข $ vi /etc/sysconfig/apache2 เพิ่ม security2 ต่อท้ายใน APACHE_MODULES="...a2enmod ssl"
Error: Invalid command 'SecRuleEngine', perhaps misspelled or defined by a module not included in the server configuration
แก้ไข $ vi /etc/sysconfig/apache2 เพิ่ม security2 ต่อท้ายใน APACHE_MODULES="...security2"
Error: Failed to open debug log file: /srv/www/logs/modesec_debug.log
แก้ไข $ mkdir /srv/www/logs
$ touch /srv/www/logs/modesec_debug.log
$ rcapache2 restart -DSSL
Troubleshooting:
Monitoring log files
$ tail -F /var/log/apache2/*
Check your SSL
$ httpd2 -S -DSSL
9). Enabling ldaps secure ldap authentication (ออปชั่นเพิ่มเติม)
เพิ่ม module "mod_ldap"
$ vi /etc/sysconfig/apache2 เพิ่ม security2 ต่อท้ายใน APACHE_MODULES="...mod_dap"
$ vi /etc/apache2/conf.d/subversion.conf
10). Import Project (svn import)- เพิ่มข้อมูลเข้าสู่ repository
$ svn import test-project1 https://192.168.1.37/repos/myprojects -m "Initial import"
รอไปเจอะถึง
Committed revision 1.
test-project1 คือไดเร็คทอรี sources program เราที่ได้สร้างไฟล์ไว้แล้ว
https://192.168.1.37/repos/ คือ ตำแหน่งของ repository บน server
myprojects คือที่เก็บไว้ใน repository ที่ได้สร้างไว้ก่อนหน้านี้แล้ว
11). Export Project (svn checkout)- ดึงไฟล์ออกจาก repository
สำหรับ Linux โดยใช้คำสั่ง (ให้ทดสอบอีกเครื่อง)
$ mkdir test-svn-checkout
$ cd test-svn-checkout
$ svn checkout https://192.168.1.37/repos/myprojects
หรือ
$ svn co https://192.168.1.37/repos/myprojects
รอนิดหนึ่ง จะได้ไดเร็คทอรี่ และไฟล์กลับมา
Checked out revision 3. (revision 3 การ commit แต่ละครั้ง ตัวเลข Revision จะเพิ่มทีละหนึ่ง)
$ cd myprojects
$ ls
*** เก็บเห็นว่ามีไดเร็คทรอรี่เพิ่มเข้ามา ชื่อ .svn/ โดยจะเป็นส่วนที่เก็บคอนฟิกและการตรวจสอบการเปลี่ยนแปลงไฟล์ของ subversion ห้ามลบทิ้ง
12). Verify svn files version (svn info) - ใช้สำหรับตรวจสอบเวอร์ชั่น (Revision) และข้อมูลการเปลี่ยนแปลงล่าสุดของไฟล์
$ cd myprojects
$ svn info
Path: .
URL: https://192.168.1.37/repos/myprojects
Repository Root: https://192.168.1.37/repos/myprojects
Repository UUID: dc7ed4ec-4a7c-11de-9e40-47b810e29cd1
Revision: 3
Node Kind: directory
Schedule: normal
Last Changed Rev: 3
Last Changed Date: 2009-05-27 13:33:47 +0700 (Wed, 27 May 2009)
13). Checking status (svn status) - ตรวจสอบสถานะของการแก้ไขไฟล์
ทดสอบแก้ไขไฟล์ที่เครื่อง client (linux desktop)
$ cd /srv/svn/repos/myprojects
$ vi license.html
ลองพิมพ์อะไรเพิ่มเข้าไปดู
$ svn status
M license.html
เมื่อมีการเปลื่ยนแปลงจะมีอักษรย่อ เพิ่มเข้ามา ตัวอย่าง เช่น
M ไฟล์มีการแก้ไข
A ไฟล์ถูกสร้างขึ้นมาใหม่
D ไฟล์ถูกลูบไป
? ยังไม่มีข้อมูล
14). Commit (svn commit) - เมื่อแก้ไขเสร็จก็ต้องส่งเข้าใน repository ด้วยคำสั่ง svn commit
*** ระบุออปชั่น ‘-m’ เพื่อใส่คำอธิบายการแก้ไข
$ svn commit -m "added more lines"
Authentication realm: <https://192.168.1.37:80> LDAP Authorization Realm
Username: sontaya.photibut
Password for 'sontaya.photibut': (ใสรหัสผ่านของเราที่อยู่บน database ldap)
Sending license.html
Transmitting file data .
Committed revision 4.
***เนื่องจากเรามีการคอนฟิกให้ Authentication กับ LDAP ด้วยซึ่งต้องใส่รหัสผ่านก่อนถึงจะ commit ได้.
15). Adding file (svn add) - เพิ่มไฟล์ที่สร้างขึ้นใหม่
$ vi license-new.html
$ svn add license-new.html
$ svn commit -m "added a new file "
16). Deleting file (svn delete) - ลบไฟล์ออก
$ svn delete license-new.html
$ svn commit -m "deleted a new file "
17). ติดตั้ง TortoiseSVN (SVN Client) for windows
Tortoisesvn (svn client) ถือได้ว่าเป็นโปรแกรมสำหรับโปรแกรมเมอร์ บนวินโดวส์อีกตัวที่ได้รับความนิยมเป็นอย่างมากสำหรับโปรแกรมเมอร์ในการพัฒนาโปรแกรมร่วมกันหลายๆ คน อีกอย่างฟรีด้วยครับ.
คุณสมบัติ:
protocols supported
-http://
-https://
-svn://
-svn+ssh://
-file:///
-svn+XXX://
การใช้งานเบื้องต้น:
1. ดาวน์โหลดได้จาก http://tortoisesvn.net/downloads
2. สร้างโฟลเดอร์ สำหรับเก็บไฟลชื่อ myproject > คลิกขวาเลือก TortoiseSVN > Settings
3. คลิกที่ปุ่ม Edit จากนั้นจะเห็นหน้าต่างโปรแกรม Notepad เปิดขึ้นมา
4. ค้นหาบรรทัด (กด Ctrl+F) คำว่า # enable-auto-props = yes ให้แก้โดยเอาเครื่องหมาย # ออก
5. ค้นหาบรรทัด # *.c = svn:eol-style=native ท้ายบรรทัดนี้ให้เพิ่ม เช่น
*.c = svn:eol-style=native
*.cpp = svn:eol-style=native
*.h = svn:eol-style=native
*.dsp = svn:eol-style=CRLF
*.dsw = svn:eol-style=CRLF
*.sh = svn:eol-style=native;svn:executable
*.txt = svn:eol-style=native
*.png = svn:mime-type=image/png
*.jpg = svn:mime-type=image/jpeg
Makefile = svn:eol-style=native
SConscript = svn:eol-style=native
SConstruct = svn:eol-style=native
Distfiles = svn:eol-style=native
*.url = svn:eol-style=CRLF
*.bat = svn:eol-style=CRLF
*.pas = svn:eol-style=CRLF
*.dfm = svn:eol-style=CRLF
*.pl = svn:eol-style=native;svn:executable
*.pm = svn:eol-style=native
*.html = svn:eol-style=native
*.pm = svn:eol-style=native
*.py = svn:eol-style=native
*.js = svn:eol-style=native
*.css = svn:eol-style=native
*.pc = svn:eol-style=native
*.svg = svn:eol-style=native
*.xs = svn:eol-style=native
*.po = svn:eol-style=native
*.pot = svn:eol-style=native
จากนั้นก็บันทึก เป็นอันเสร็จ
6. ที่โฟลเดอร์ "myproject" คลิกขวา แล้วเลือก SVN Checkout จะขึ้นหน้าต่างให้ใส่ URL
ให้ใส่ https://192.168.1.37/repos/myprojects แล้วคลิก OK
7. รอจนกว่ามันจะดึงข้อมูลลงมาเสร็จ
8. ถ้าแก้ไขไฟล์เสร็จแล้วก็ คลิกขวาที่ไฟล์ แล้วเลือก commit จากนั้นจะขึ้นหน้าต่างให้ใส่ ชื่อผู้ใช้ และรหัสผ่าน เป็นอันเสร็จครับ.
Path cache passwords: cat ~/.subversion/auth/svn.simple/filename
Ref.
http://en.wikipedia.org/wiki/Subversion_(software)
http://subversion.tigris.org/
http://tortoisesvn.net/support
http://www.novell.com/communities/node/5679/installing-and-configuring-subversion-server-and-apache2-ldap-authentication-against-edire#9
http://spalinux.com/2008/11/basic_using_subversion
http://blogs.open.collab.net/svn/2007/03/subversion_ldap.html
END.

written by personal loans, November 12, 2011
SUSE Linux Enterprise Cool Solutions
|












