Sunday, October 12, 2008

Install Subversion บน Windows

เนื่องจากบนเน็ท ทั้งใน Blog คนไทยและคนต่างประเทศ ทำตามแล้วไม่ตรง เนื่องจากมีการเปลี่ยนแปลงคำสั่งของ SVN Server เล็กน้อย บวกกับคนที่เป็น Newbie ย่อมงงเป็นธรรมดา

ไหนๆก็งงมาตั้งนานขอเอามา post เก็บไว้เผื่อใครมาติดแบบผมจะได้ไปได้ไว

INTRODUCTION

เราจะติดตั้งระบบ Subversion เพื่อใช้ในการภายในครับ Software ที่ใช้ได้แก่
- CollabNet Subversion ผมใช้ CollabNetSubversion-server-1.5.2-2.win32.exe
เป็น Installer สำเร็จ ส่วนจะสำเร็จไม่สำเร็จนั้นอีกเรื่องหนึ่ง... เอ้อ ผมเป็น Server โหลดที่ีนี่ครับ
http://www.collab.net/downloads/subversion/

- ตัว Tortoise SVN ถือว่าจะใช้เป็น Client ครับ ผมใช้ TortoiseSVN-1.5.3.13783-win32-svn-1.5.2.msi
โหลดไว้ซักพักแล้ว เป็น Installer สำเร็จจริงๆ ก็ลงแล้วใช้ได้เลยนะ โหลดที่นี่ครับ
http://tortoisesvn.net/downl
oads

มีแค่ 2 ตัวนี้ละครับ ที่จริงผมลอง WinCVS ด้วย เดี๋ยวจะเล่าถึงความงงให้อ่านทีหลัง

เริ่มกันเลย
1. ทั้ง 2 ตัวไม่ขึ้นต่อกัน (as far as I know นะครับ) ลงไปเลย แต่ก็จะเขียนตามที่ผมทำละกันครับ
บังเอิญผมลง เจ้า Tortoise SVN ก่อนครับ ก็ลงปกติ

เลือก Path ที่จะลง จะไว้ใน Program file ก็ได้ครับ หรือจะไว้ drive อื่นก็ไม่เป็นปัญหา
Next โลด แล้วเสร็จก็ Restart เครื่องซะ 1 ที

2. เสร็จแล้วมาลง CollabNet Subversion Server กัน เป็น Installer ก็เลือกตามไปปกติครับ

มันให้เลือกเลือก port ของ Subversion ปกติก็เลือก 3690

มันให้เลือกที่อยู่(Folder ของ Repository) ผมก็เลือกตามมัน เปลี่ยนหน่อยตรงที่ผมให้มันอยู่ Drive D:
เป็น D:\svn_repository ก็ธรรมดานะ

มันให้เลือก port ของ Apache (โอ้โห มี Apache ให้ด้วย) ผมไม่เอา 80 เพราะจะชนกะตัวอื่น ผมยังไม่รู้ว่าจะกระทบอะไรเมื่อไร แต่ถ้าทราบแล้วจะเอามาเขียน update ครับ (แต่ว่าตอนใช้งาน ผมก็ไม่ระบุ port นะถึงจะสร้าง project ได้ ก็ยังงงๆอยู่เหมือนกันคนับว่าจะไปใช้ตอนไหน เชื่อว่าใช้กับ Client ที่เป็น Browser อยู่แล้วละนะ)

มันให้เลือก Repository Folder อีกแล้ว ผมก็ว่าอะไรนักหนานะ แล้วก็ใส่ให้มันตามเดิม แล้ว Next
(ขออภัยครับ ไม่ได้มีรูปเลย)

มันให้เลือกอะไรอีกนิดหน่อย ผมจำไม่ได้ มีการให้เลือกว่าจะให้ View Tools อะไรซักอย่าง เข้าถึงได้มั้ย
บังเอิญผม Setup แบบ Newbie ก็ขอเปิดด้วยละกัน เพราะคุ้นๆว่าอาจได้ใช้ แล้วก็ไม่ได้ห่วย Security เพราะจะใช้ใน LAN

จบแล้วครับ มันควรจะใช้ได้ แต่ยังครับ

3. เราต้องแก้ไข user-password ของ Subversion ซักหน่อย
ผมอ่านตามเวบนี้ครับ
http://blogs.vertigosoftware.com/teamsystem/archive/2006/01/16/Setting_up_a_Subversion_Server_under_Windows.aspx
ข้ามไปข้อ C) ของเค้าเลยนะครับ เพราะก่อนหน้านั้น Wizard ของการลง ColabNet นั้นจัดการเรียบวุธไปแล้ว

ขออนุญาติเอามาแปะไว้นะครับ (ขอมันซะที่ประเทศไทยนี่แหละ)

C) Create a Repository

  1. Open a command prompt and type อันนี้เค้าจะสร้าง Repository ที่จริง Wizard ทำแล้วแต่พอเราเข้าไปดูจะเห็นเป็นแค่ Folder เปล่าๆครับ ทีแรกผมสร้างใหม่ อีก Folder หนึ่ง แต่แนะนำว่าใช้อันเดิมไปเลย (เพราะตอนท้ายเราจะไม่ต้องมาแก้ Service ที่ Wizart Gen เอาไว้ให้แล้ว)
    svnadmin create "c:\Documents and Settings\Subversion Repository" ก็พิมพ์ตามนี้ครับ แก้ Folder เป็นของคุณเองนะครับ
  2. Navigate to the folder we just created. Within that folder, uncomment the following lines in the /conf/svnserve.conf file: แก้ Conf file ที่ Folder ที่สร้างขึ้น
    [general]
    anon-access = read
    auth-access = write
    password-db = passwd

    Next, uncomment these lines in the /conf/passwd file:

    [users]
    harry = harryssecret
    sally = sallyssecret
มีการตั้ง user/password ด้วย ตั้งที่ File passwd นี่หละครับ (บังเอิญผมไม่สนเรื่องความปลอดภัยอะไรอะครับ)

4. ตรวจตามเค้า

D) Verify that everything is working

  1. Start the subversion server by issuing this command in the command window:
    svnserve --daemon --root "C:\Documents and Settings\Subversion Repository"    

    ตรงนี้หน้าจอ conmmand จะค้างนะครับ
    ไม่ต้องแปลกใจเพราะเป็นการตั้งใจของเค้าที่จะรันโปรแกรมเอง ก่อนที่จะไปทำ Service
  2. Create a project by opening a second command window and entering this command:

    svn mkdir svn://localhost/myproject

    ให้เปิดหน้า command ใหม่ขึ้นมาแล้วทำต่อ ตรงนี้ที่ผมงงว่าตกลงใช้ port อะไรแต่ที่ลอง ไม่ต้องใส่ port ครับ
    แม้ว่าผมจะ set ให้ Apache เป็น port อื่นไปก็ตาม ก็ต้องไม่ใส่ port

    It's a standard Subversion convention to have three folders at the root of a project:
    เค้าว่ามันจะสร้าง Folder ตามนี้ ผมก็ยังไม่เห็นนะ

    /trunk
    /branches
    /tags

  3. At this point, Notepad should launch: พอเรา enter ในขั้นตอนที่แล้วปุ้บ มันก็จะขึ้น Editor ขึ้นมาให้ใส่ comment ก็ใส่ไปครับ แต่อย่าใส่ข้างล่างบรรทัดที่เขียนว่า --This line, and those below, will be ignored-- ให้ใส่ข้างบน (อย่าถามว่าทำไปนะครับ.. ไม่รุ็อะ)

    Enter any comment you want at the top of the file, then save and exit.เสร็จแล้ว save แล้วปิดไปเลย ไม่ต้อง Save As นะครับ จะทับยังไงก็ช่างมันดีกว่ามั้ง
  4. You'll now be prompted for credentials. In my case I was prompted for the administrator credentials as well: อะฮ้า มีให้ใส่ password ของเครื่องที่เราใช้ด้วยครับ เอ..จะใส่ดีมั้ยนะ แต่ก็ใส่ๆไป และมีถามต้่อเรื่อง User กับ Password ใช้ใช้อันที่เราตั้งใน passwd.conf นะครับ

    Authentication realm:  0f1a8b11-d50b-344d-9dc7-0d9ba12e22df
    Password for 'Administrator': *********
    Authentication realm: 0f1a8b11-d50b-344d-9dc7-0d9ba12e22df
    Username: sally
    Password for 'sally': ************

    Committed revision 1.

    Congratulations! You just checked a change into Subversion!


5. สร้างเป็น Service จริงๆอันนี้เราทตามเค้าไม่ได้เพราะ SVNService.exe เราไม่มี งงไปนานแต่ดูดีๆมันถูกเป็นเป็นคำสั่งนี้ไปแล้วครับ
svnserve.exe" --service -r "D:\svn_repository" --listen-port "3690"

สิ่งที่ผมทำคือเข้าไปใน Service ใน Administative Tools > Service
แล้วสั่ง Start มันเองเลย.. อะนะ
ดังนั้นเราไม่ต้องทำตามเค้า แต่เราทำการทดสอบตามเค้าได้ครับด้วยคำสั่ง
svn ls svn://localhost/

เอาของเค้ามาให้ดูด้วย

E) Start the server as a service

  1. Stop the existing command window that's running svnserve by pressing CTRL+C.
  2. Copy the file SVNService.exe from the zip file of the same name to the subversion\bin folder.
  3. Install the service by issuing the following commands:
    svnservice -install --daemon --root "C:\Documents and Settings\Subversion Repository"
    sc config svnservice start= auto
    net start svnservice
  4. Test the new service by listing all the files in the repository:
    svn ls svn://localhost/

    You should see the single project we created earlier, myproject/


เสร็จแล้วก็น่าจะทำตามตัวอย่างเค้าได้เลย (พอดียังไม่ได้ลอง มาเขียน Blog ก่อน)
ตามนี้ครับ

F) Set up the shell extension

  1. Run the TortoiseSVN installer. It will tell you to restart, but you don't need to.
  2. Create a project folder somewhere on your hard drive. Right click in that folder and select "SVN Checkout..."



    type svn://localhost/myproject/ for the repository URL and click OK.


  3. Create a new file in that directory. Right click the file and select "TortoiseSVN, Add"


  4. The file hasn't actually been checked in yet. Subversion batches any changes and commits them as one atomic operation. To send all your changes to the server, right click and select "SVN Commit":



And we're done! You now have a networked Subversion server and client set up on your machine. Note that the default port for svnserve is 3690.

For more tips on using subversion, take a look at the free O'Reilly Subversion book.


posted on Monday, January 16, 2006 4:15 PM by jatwood

จบแล้วครับ
การ Setup แบบ Newbie จริงๆ ได้ผลยังไงจะเขียนเพิ่มครับ
หรือใครจะติชมก็ยินดีมากๆครับ


REFERENCES
ขอเพิ่มเติม Link น่าอ่านสำหรับ Newbie อีครับ ตามนี้

http://www.narisa.com/forums/index.php?showtopic=18875
[รบกวนเรื่องการใช้งานและลง SVN version server ด้วยครับ, ผมคิดว่าเพื่อนๆหลายคนก็คงจะศึกษาเรื่องนี้กันอยู่]

http://www.narisa.com/forums/index.php?showtopic=16023
[TortoiseSVN หรือ SVN ตัวอื่น ๆ มีใครเคยใช้บ้างค่ะ]

http://blogs.vertigosoftware.com/teamsystem/archive/2006/01/16/Setting_up_a_Subversion_Server_under_Windows.aspx
[อันนี้เป็น Link นอกที่อ่านรู้เรื่องสุดแล้วมั้งครับ]

สู้ๆครับ :-)

9 comments:

Anonymous said...

Pretty! This was an extremely wonderful article. Many thanks for supplying this info.



Also visit my blog seo expert uk

Anonymous said...

Yesterday, while I was at work, my cousin stole my iphone and tested to see if it can survive a forty foot drop, just so she can be
a youtube sensation. My apple ipad is now broken and she
has 83 views. I know this is totally off topic but I had to share it
with someone!

Visit my website: alle privaten krankenversicherungen

Anonymous said...

I really like what you guys are up too. Such clever work and coverage!
Keep up the very good works guys I've incorporated you guys to my personal blogroll.

Feel free to surf to my webpage top business ideas

Anonymous said...

Thank you for the auspicious writeup. It in truth was once a
leisure account it. Glance complex to more brought agreeable from you!
However, how can we keep in touch?

my page clickbank pitch page

Anonymous said...

I constantly spent my half an hour to read this website's articles all the time along with a cup of coffee.

My homepage :: qualify for mortgage with bad credit

Anonymous said...

I was recommended this web site by way of my cousin. I am now not sure
whether this put up is written by means of him as nobody else understand such distinct
approximately my difficulty. You are wonderful! Thank you!


Here is my web-site handyvertrag trotz schufa

Anonymous said...

Every weekend i used to pay a visit this website, because i
wish for enjoyment, as this this web site conations actually nice funny stuff too.


Here is my web-site ... what is work from home jobs about

Anonymous said...

Pretty nice post. I simply stumbled upon your weblog and wanted to say that
I've really enjoyed surfing around your weblog posts. In any case I'll be subscribing in your rss
feed and I am hoping you write once more very soon!

Here is my weblog: Private Krankenversicherung Anwartschaft

Anonymous said...

I under no circumstances post, but now I want to give thanks
for a really very good diary.

Review my site :: günstig urlaub