Install SVN and implement Nginx Web Sync update on the basis of WDCP one-click installation package

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Install SVN and implement Nginx Web Sync update on the basis of WDCP one-click installation package

I. Installation

1. See if CVS are installed

Rpm-qa | grep subversion

2. Installation

Yum Install Subversion

3. Test Installation Success

/usr/bin/svnserve--version

If you are prompted with the following, you have successfully installed

--------------------------------------

Svnserve, Version 1.6.11 (r934486)

Compiled in Apr 11 2013,17:28:04

Copyright (C) 2000-2009 collabnet.

Subversion is open source software, see the http://subversion.tigris.org/site.

This product contains software developed by CollabNet (http://www.Collab.Net/).

The following version of the Library backend (FS) module is available:

* Fs_base: module can only operate BDB version library.

* FS_FS: module works with the text file (FSFS) version Library.

Cyrus SASL certification is available.

--------------------------------------------------------------

II. Configuration

1, create a new directory: Repos can be used to store svn all files

Mkdir-p/opt/svndata/repos

Note that the directory (project name) path here can be changed in the following format:

Mkdir-p directory path (such as: Mkdir-p/www/svn/project)

2, create a new version of the warehouse (using the Svnadmin Create directory warehouse path with the new directory to be consistent)

Svnadmin Create/opt/svndata/repos

3, modify the SVN version of the library profile

Vi/opt/svndata/repos/conf/svnserve.conf

Modified in the following format, where the realm value is the project name, in this case repos.

[General]

Anon-access = None

auth-access = Write

Password-db =/opt/svndata/project/conf/passwd

Authz-db =/opt/svndata/project/conf/authz

Realm = Repos

Note: Changes to user profiles take effect immediately and do not need to reboot SVN.

4, add Users

vi/opt/svndata/repos/conf/passwd

Adding an SVN user is very simple, just add a "Username=password" entry to the/opt/svn/project/conf/passwd file.

To test, I added the following:

[Users]

# Harry = Harryssecret

# sally = Sallyssecret

PM = PM_PW

Server_group = SERVER_PW

Client_group = CLIENT_PW

Test_group = TEST_PW

5. Modify User Access Policy

Vi/opt/svndata/repos/conf/authz

To record the user's access policy, the following are references:

[Groups]

project_p = PM

project_s = Server_group

Project_c = Client_group

project_t = Test_group

[project:/]

@project_p = RW

* =

[Project:/server]

@project_p = RW

@project_s = RW

* =

[Project:/client]

@project_p = RW

@project_c = RW

* =

[Project:/doc]

@project_p = RW

@project_s = RW

@project_c = RW

@project_t = RW

* =

The above information indicates that only PM has the right to read and write the root directory, Server_group can access the server directory, Client_group can access the client directory, everyone can access the doc directory.

Of course, the above is more complex permissions control, if only testing, can be simpler. Set up a user group, put all users into a user group, as follows:

[Groups]

admin = Pm,server_group,client_group,test_group

[/]

@admin = RW

On the control of the rights, this article does not describe the details, we can go to consult Niang.

5. Start SVN service

svnserve-d--listen-port 3690-r/opt/svndata/repos (run as Root)

If more than one project is being developed at the same time, you can open multiple SVN services via different ports, and remember to add the port number when using the TORTOISESVN operation.

6. Test SVN server

Go to Site root directory

Cd/www/web/repos/public_html

SVN co svn://127.0.0.1:3690/www/web/repos/public_html--username pm--password PM_PW

The following authentication prompts appear

-----------------------------------------------------------------------

Note! Your password, for the authentication domain:

Repos

Can only be saved in plaintext on disk! If possible, consider configuring your system to allow subversion

You can save the encrypted password. See the documentation for more information.

You can set the option "Store-plaintext-passwords" to "yes" or "no" in "/root/.subversion/servers".

To prevent this warning from appearing again.

-----------------------------------------------------------------------

Save unencrypted password (yes)?

Enter the "Yes" carriage because the version warehouse has not added any files, so take out the version 0, as follows:

Remove version 0.

Third, configure Post-commit, implement automatic synchronization svn version library files to the Web directory

To allow the Web server to synchronize directly after the modified code has been submitted to the SVN server. You need to configure SVN hooks to enter the hooks directory,

Cd/opt/svndata/repos/hooks

ls

You can see that there is a Post-commit.tmpl file, which is a template file that copies a copy in this directory, named Post-commit, and sets its user group to WWW and set it to executable:

CP Post-commit.tmpl Post-commit

Chown www:www Post-commit

chmod +x Post-commit

This will have access to the WWW directory.

The original code is all commented out. You can execute the shell command, which is invoked every time a commit completes.

The contents of the file refer to the following:

VI Post-commit

#!/bin/sh

Export LANG=ZH_CN. UTF-8

Repos= "$"

rev= "$"

Svn_path=/usr/bin/svn

Web_path=/web/web/repos/public_html

Log_path=/tmp/svn_update.log

#/usr/bin/svn Update--username user--password password $WEB _path--no-auth-cache

echo "nnn######### #开始提交" "Date" +%y-%m-%d%h:%m:%s "' ################## ' >> $LOG _path

Echo ' WhoAmI ', $REPOS, $REV >> $LOG _path

$SVN _path update--username user--password password $WEB _path--no-auth-cache >> $LOG _path

Chown-r www:www $WEB _path

Description:

1, #!/bin/sh description is to execute the shell command/* Set environment variables, if not set may appear update error

2, Export LANG=ZH_CN. UTF-8 is to resolve the SVN post commit Chinese garbled.

If you are GBK encoding may be prompted: Error output could not is translated from the native locale to UTF-8

This is a client-and server-encoded issue, by default Utf-8, which you can try to set up export LANG=ZH_CN. GBK or export Lang=en_us. UTF-8

#执行更新操作

3, SVN update–username your version of the library's username –password username password svn://Your IP address: port/web/web/repos/public_html

4. Chown-r www:www $WEB _path Change the folder owner to fit the WEB server

The original code is all commented out. You can execute the shell command, which is invoked every time a commit completes.

This article is excerpted from the Wdlinux Forum, reproduced please specify ~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.