Svn configuration on centos7

Time:2020-9-24

Reprint:
https://blog.csdn.net/weixin_39218464/article/details/104093559
https://blog.csdn.net/jctian000/article/details/80623621

After a while, it is better to record it for later use (SVN needs to be installed first)

For future planning, multiple warehouses can be configured

1. First create the general warehouse Directory:

mkdir -p /home/svn/project

2. Create a folder for the warehouse in the general directory and create a version library using the command:

MKDIR - P / home / SVN / project / your project 1
Svnadmin create / home / SVN / project / your project 1

In the future, other projects can use the following commands (and so on) if necessary:

MKDIR - P / home / SVN / project / your project 2
Svnadmin create / home / SVN / project / your project 2

3. If it is multiple projects, it is convenient to manage. Go to the conf folder in your project 1 directory. Copy the authz and passwd files in it to the project directory (if single project ignores this step)

CD / home / SVN / project / your project 1
cp authz ../../
cp passwd ../../

4. Modify the authz and passwd files
4.1. Passwd is the user account configuration
As shown in the figure below, before the equal sign is the account number, followed by the password
Svn configuration on centos7
4.2. Authz is the permission configuration
As shown in the figure below, it is only a simple and crude configuration. All projects have read and write permissions. If necessary, you can baidu
Svn configuration on centos7

5. Finally, modify the SVN service configuration file svnserve.conf
As shown in the figure below:
Svn configuration on centos7
Note that password dB and authz dB in the picture are multi project configurations that represent a common user and permission configuration. Please delete both of the items in the single item, only the English letters are reserved

6. Starting and shutting down the SVN service
6.1. Start up:

svnserve -d -r /home/svn/project/

6.2. Closing:

killall svnserve

At this point, the configuration of SVN can be finished.

Let’s record the development with the web

Step 1: set the hook to update automatically

To realize the synchronization of SVN and web, you can either co out one by one, or directly use the method of automatically updating the web directory. We need to configure the hook in the SVN version library, that is to create a post commit configuration file and configure it simply. In four simple steps, SVN can automatically update the web directory configuration under Linux.
1. Create your web application directory

mkdir -p /home/wwwroot

2. Enter the web application directory you created (SVN checkout can be abbreviated as CO)

cd /home/wwwroot

3. Check out

Do not rename the folder, check it out directly in the current directory

svn checkout  svn://localhost/ Your project 1

Check out files and rename folders

svn checkout  svn://localhost/ Your project 2 your project 3

Step 2: create a new post commit file [hook Script] in the hooks / directory of the project library

Add script content as follows

export LANG=en_US.UTF-8`
DIR=/home/wwwroot
Web=/home/wwwroot/ your project
svn update $WEB --username joy --password 123456 --no-auth-cache
chown -R www:www $WEB

Web = change the right to your actual web directory

Step 3: let post commit have execution permission

chmod a+x post-commit

Step 4: This is done. Step 4 is testing.

explain:
export LANG=en_ US.UTF -8 is to solve the problem of Chinese garbled code in SVN post commit, because my system encodes utf8. In fact, SVN defaults to UTF-8 encoding. If the encoding is GBK, if it is not set, an error will occur and the execution will not succeed. The error identifier is

svn: Can`’t convert string from native encoding to ‘`GBK'

/Usr/bin/svn update –username CQH –password 123456 /var/www/html/test to perform the update operation
If prompted:

post-commit hook failed (`exit code 255) with no output`

Give the post commit file executable permission
If your default encoding is UTF-8, to upload a Chinese file, first save the file as UTF-8 format before submitting