As programmers, we should try more. In rabbitMQ writing, the operation of SVN between the host machine and the virtual machine is not easy to capture. In order to show you a better effect, I will write the operation flow of SVN between the host machine and the virtual machine.

This paper mainly focuses on the following aspects

  • Install SVN
  • Connect to the SVN of the VM on the host
  • Use hooks to synchronize to the Web directory
  • Use SVN for multiple projects
  • SVN user permission Settings

Implementation environment of this paper

  • centos7.3
  • All operations are performed on the VM

1. Install the SVN

Yum install Subversion

performsvn --versionView the version number and check whether the installation is successfulCreate a public directory for the repository. In /var/, create a directory for the SVNmkdir /var/svn

Of course this can be customized directory, depending on personal habitsThen came tovar/svnDirectory, create a version library

If you run svnadmin create /var/svn/kaka, there will be a blog version library in your SVN directory.

Into thekakaThe version of the libraryvar/svn/kaka/confYou can see three files

Auth: indicates the file of control permission passwd: indicates the file of control password svnserve.conf: indicates the configuration information of the SVNModify the configuration information on svnserve.conf. Change all the information circled in red.Next set the password and open the filepasswd Set permissions, here is the role followed by the user Settings of the user nameAnd then I’m going to change thatpasswdandauthzMove the file to the same directory as the repository and execute the commandmv passwd authz /var/svn This step completes the installation and configuration of the SVN. Next, the host machine connects to the SVN of the virtual machine

2. The host connects to the SVN of the VM

Pay attention to the IP addresses of VMSThe host first needs to have a SVN client, this installation will not say, next after all ok.

Enable the SVN service and run the following commandsvnserve -d -r /var/svn/And check whether the function is enabled successfullyWhen the host starts to connect, the address is the IP address of the VM, and the account password is admin 123456At this point, the file has been cloned locallyThe test upload file also succeededHere we connect to SVN on the host and submit the file to SVN successfully.

Three, automatic synchronization to the Web environment

/usr/local/nginx/html since the web directory is not configured on the virtual machine, it is directly under /usr/local/nginx/html

will/var/svn/kaka/hooksUnder thepost-commit.tmplInstead ofpost-commit An instruction tomv post-commit.tmpl post-commitAnd the permissions are fullModify thepost-commitThe contents of the file, but when you open the file, it’s just a bunch of comments, clicking a command to delete it all

perform100 ddDelete 100 linesAnd add some content

#! /bin/sh
Set the environment variable. If you do not set the environment variable, an update error may occur
 
export LANG='zh_CN.UTF-8' 
 
SVN_PATH=/usr/bin/svn WEB_PATH=/usr/local/nginx/html/kaka/  LOG_PATH=/tmp/svn_update.log $SVN_PATH update $WEB_PATH ~ Copy the code

Save exit, we locally in the submission of a new file, a new 456.txt file to submitGo to the Web directory to see if there are files/usr/local/nginx/html.

Obviously there is no such file. Don’t panic!/usr/local/nginx/htmlThis directory is the last step in the operation

Execute instructions:SVN co - the username admin password 123456 SVN: / / 192.168.254.135 / kakaAt this time, the files of our host computer have been cloned to our VIRTUAL machine through SVN.Upload it to the local computer again to see if it can be directly uploaded to the VIRTUAL machine.

It’s been tested and it’s ok.

Iv. Use SVN for multiple projects

In fact, in the screenshot above you can see that there is a version of the blog in my version library.

The operation steps are exactly the same as kAKA’s version library. Just delete the blog/conf passwd and authz files

That is, multiple repositories use the same permissions and account passwordsUpload a 258.txt to kaka and blog at the same time At this point, you can use the same SVN for multiple projects.

5. Setting user permissions

Why do you need to set this user privilege distinction?

For example, when you send code to SVN, a new colleague comes to the company. He needs to be familiar with the code, but he can only pull the code but not submit it.

At this point, you need to set user permissions. To the whole up

Login user newA new user with only r permission and no W permission cannot submit the file