Deploy web version synchronization in apache + svn under Centos6.3

Source: Internet
Author: User
Tags svn client svn update tortoisesvn

I have been busy with projects some time ago, so I haven't had time to update the svn service in the early stage of the project. Today I just finished my work and summarized my previous configurations for your reference.

As an open-source code version management software, svn (subversion) is a synchronization software widely used by project developers to upload local source code to the web Test server.

It stores version data in two ways: BDB (a transaction-safe table type) and default FSFS (a storage system that does not require a database ). Because BDB may lock data when the server is interrupted, it is safer to use FSFS.

This blog post aims to enable developers to use the svn client in windows to upload the source code to the svn repository on the server, and use the svn hock script to synchronize the database data to the apache directory, to test the web page in real time.


My new blog website has been created, and more new content will be updated on the new site soon ..

WelcomeHttp://www.showerlee.com



Solution:


1. Environment deployment


Operating System: centos6.3 x64

SVN: subversion-1.8.0

Apache: httpd-2.4.4


650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1135114333-0.jpg "title =" svn?apache.jpg "/>


Svn server (centos6.3 x64): 192.168.7.74

Svn client (win7 x64): 192.168.7.129


1. Disable iptables and SELINUX

# Service iptables stop

Note: To enable the firewall, add the following rule to open the svn port 3690.

# Iptables-a input-p tcp -- dport 3690-j ACCEPT

# Setenforce 0

# Vi/etc/sysconfig/selinux

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

SELINUX = disabled

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


2. Synchronization time

# Ntpdate asia.pool.ntp.org


3. install apache

Transport: http://showerlee.blog.51cto.com/2047005/1174141


4. Disable built-in svnserve.

# Service svnserve stop

# Chkconfig svnserve off

Note: To avoid compatibility issues with apache2.4.4, this document uses the latest version of svn, Which is disabled here to ensure that it does not conflict with the version of rpm.


Ii. svn installation and configuration:

(Svn server)


1. download and install the svn source code package

# Wget http://mirrors.tuna.tsinghua.edu.cn/apache/subversion/subversion-1.8.0.tar.bz2

# Tar jxvf subversion-1.8.0.tar.bz2

# Cd subversion-1.8.0

Create installation directory

# Mkdir-p/usr/local/svn


2. Install the svn dependency package and decompress the module to the svn root directory:

# Wget http://www.sqlite.org/sqlite-amalgamation-3071501.zip

# Unzip sqlite-amalgamation-3071501.zip

# Mv sqlite-amalgamation-3071501 sqlite-amalgamation

Compile and install

#./Configure -- prefix =/usr/local/svn

# Make & make install


Test whether the installation is successful

#/Usr/local/svn/bin/svnserve -- version

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

Svnserve, version 1.8.0 (r1490375)

Compiled on Jun 29 MAID: 08: 41 in x86_64-unknown-linux-gnu

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

Note: centos6.3 is installed with the svn server by default. The version is 1.6.11. The svn command is loaded by environment variables under/usr/bin/svn. The version compiled in this document is 1.8.0, we do not recommend that you use the svn commands of earlier versions to perform the following operations. An error may occur. We recommend that you directly access the compiled high-version svn commands in the full path and perform the following operations to distinguish them.


3. Configure svn

1). To create a version library directory, separate the installation directories)

# Mkdir-p/data/svndata/www.example.com


2) Create the svn version Library

# Svnadmin create/data/svndata/www.example.com

Note: After executing this command, svn automatically adds the required configuration file under the/data/svndata/directory.

# Ls/data/svndata/www.example.com

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

Conf db format hooks locks README.txt

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

Note: unlike normal folders, creating a file directly on the operating system cannot be recognized by SVN. You must use commands such as import to import the file to the version library. this is an internal svn command. create is used to create a version library. Use svn help to view detailed instructions.


3). Modify the version library configuration file

# Vi/data/svndata/www.example.com/conf/svnserve.conf

Modify the following configurations:

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

[General]

# Preventing unauthorized users from accessing

Anon-access = none

# Grant write permission to authorized users

Auth-access = write

# Specify the password file path

Password-db = passwd

# Access control file

Authz-db = authz

# Authentication namespace. The subversion is displayed in the authentication prompt and serves as the key word cached by the credential.

Realm =/data/svndata/www.example.com

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


4). Configure the user

# Vi/data/svndata/www.example.com/conf/passwd

Add the following content:

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

[Users]


User01 = 123456

User02= 123456

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

Note: You can add multiple svn accounts, = username and password


5). Configure permissions

# Vi/data/svndata/www.example.com/conf/authz

Add the following content

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

[/]

User01 = rw

User02 = r

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

Note: lists the permissions granted to users. Including read-only r and read/write rw. Users not listed are not allowed to access


6) Start the svn Service

#/Usr/local/svn/bin/svnserve-d-r/data/svndata/


Note: This command is used to start the svn service.-d indicates that the command runs in daemon mode and svn automatically listens on port 3690. 3690 is the default port. You can use "-- listen-port =" or "-- listen-host =" to specify other ports and non-local hosts. The-r option is used to specify the root directory of the svn service, so that you can use the relative path for access without providing the complete path.


7). Check the port

# Lsof-I: 3690

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

Command pid user fd type device size/OFF NODE NAME

Svnserve 65371 root 3u IPv4 82329 0t0 TCP *: svn (LISTEN)

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


8). Set startup

# Echo "/usr/local/svn/bin/svnserve-d-r/data/svndata/">/etc/rc. local


Svn has been initially set up.


Iii. Synchronize apache configuration with svn:

1. Add the apache svn Module

# Cd ~ /Subversion-1.8.0

# Cp./subversion/mod_dav_svn/. libs/mod_dav_svn.so/usr/local/apache2/modules/

# Cp./subversion/mod_authz_svn/. libs/mod_authz_svn.so/usr/local/apache2/modules/

# Vi/usr/local/apache2/conf/httpd. conf

Add the following content to the last line:

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

LoadModule dav_module modules/mod_dav.so

LoadModule dav_svn_module modules/mod_dav_svn.so

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

Restart the apache service:

#/Usr/local/apache2/bin/apachectl restart


2. Set the svn synchronization script

Create an apache virtual directory

# Mkdir-p/usr/local/apache2/htdocs/www.example.com

Set apache as the virtual directory host by default.

# Chown-R daemon. daemon/usr/local/apache2/htdocs/www.example.com

Create a script to synchronize data from the svn database to the apache virtual directory.

# Cd/data/svndata/www.example.com/

# Vi post-commit

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

#! /Bin/sh

Export LANG = zh_CN.UTF-8

SVN =/usr/local/svn/bin/svn

WEB =/usr/local/apache2/htdocs/www.example.com

# No account or password is required by default.

# USERNAME = user01

# PASSWORD = 123456

# SVN update $ WEB -- username $ USERNAME -- password $ PASSWORD -- no-auth-cache

$ SVN update $ WEB

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

Note: This script will be triggered when svn commit is executed on the client, so that the data of the version library can be synchronized to the apache virtual directory.

Set script executable permissions

# Chmod a + x post-commit


Use checkout to create a work copy

#/Usr/local/svn/bin/svn co svn: // localhost/www.example.com/usr/local/apache2/htdocs/www.example.com/

Follow the prompts

========================================================== ======

Certification fields: <svn: // localhost: 3690>/data/svndata/www.example.com/

"Root" Password: 123456

Certification fields: <svn: // localhost: 3690>/data/svndata/www.example.com/

"User01" Password: 123456


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

Note! Your password, for the authentication domain:


<Svn: // localhost: 3690>/data/svndata/www.example.com/


Only files on disks can be stored in plain text! If possible, consider configuring your system to make Subversion

You can save the encrypted password. See the documentation for details.


You can set the option "store-plaintext-


Passwords "is" yes "or" no ",

To avoid this warning again.

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

Save Unencrypted Password (yes/no )? Yes

A/usr/local/apache2/htdocs/www.example.com/1.txt

A/usr/local/apache2/htdocs/www.example.com/2.txt

A/usr/local/apache2/htdocs/www.example.com/3.txt

Obtain version 3.


========================================================== ======

After successful svn authentication, the synchronized authentication information is stored in the apache virtual directory./www.example.com/.svn/.

Note: The three txt files synchronized here are saved data in the version library.


3. Restart the svn service:

# Killall svnserve

#/Usr/local/svn/bin/svnserve-d-r/data/svndata/


Iv. svn client Configuration

(Svn client)

1. Download TortoiseSVN and install it by default.

Http://sourceforge.net/projects/tortoisesvn/files/latest/download? Source = dlp

2. Create a version Library:

For example:

1) create a work folder on drive F and right-click SVN Checkout to create the svn Client Version Library

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/113511HJ-1.png "style =" float: none; "title =" 31.png"/>


2) enter the svn remote version library URL and local version inventory path.


650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1135115N8-2.png "style =" float: none; "title =" 8.png"/>

3) enter the username and password of the version library. By default, the account information is saved in/data/svndata/www.example.com/conf/passwd.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1135115431-3.png "style =" float: none; "title =" 9.png"/>


4). The version library is created and displayed as the first version.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1135115H5-4.png "style =" float: none; "title =" 34.png"/>

3. Synchronize the version Library

For example, if there is a new file update in the windows Client Version library, how can we synchronize data to the web end?

1) First, right-click the version library www.example.com directory and select svn Update

It is equivalent to synchronously updating the data on the svn server to the local machine to obtain the data.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1135114Y5-5.png "style =" float: none; "title =" 2.png"/>


2). Update to version 4

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/11351145c-6.png "style =" float: none; "title =" 3.png"/>

3) Right-click the version library www.example.com directory and select svn Commit

It is equivalent to synchronizing data from the local client to the svn server, that is, pushing data.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1135111335-7.png "style =" float: none; "title =" 4.png"/>


4). Hook the data to be pushed and OK to complete the operation.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/113511N24-8.png "style =" float: none; "title =" 5.png"/>

5). The version is currently the fifth.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1135113111-9.png "style =" float: none; "title =" 6.png"/>

Check whether the file is successfully pushed to the apache virtual directory.

# Cd/usr/local/apache/htdocs

# Pwd

# Ls-l

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1135115B1-10.png "title =" 7.png"/>


--------- Success -----------


This article from "all the way to the North" blog, please be sure to keep this source http://showerlee.blog.51cto.com/2047005/1240955

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.