Build the SVN service project and synchronize the code to the project directory
As the project grows, more people are needed to participate in the development of the same project. SVN is used for multiple people to jointly develop the same project and share resources.
There are two ways to run SVN server: one is as a standalone server, the other is to run with Apache. Both methods have their own advantages and disadvantages, and users can choose for themselves. Here we only discuss the first method: as a standalone server.
Create SVN repository
First we need to install the SVN application. Here we choose the operating system of centos. Installing the SVN application in Linux is actually very simple. Use the following command
# yum install svn
Then the installation process will appear. After the installation is complete, we will create a new SVN repository reptest. For ease of management, we will create a new folder to store all repositories/repos
# mkdir /repos
# svnadmin create /repos/reptest
After the creation is completed, we enter the warehouse and find that there are several files and directories in this directory
# cd /repos/reptest
# ls
conf db format hooks locks README.txt
In this way, we have created an SVN repository.
Configuring User Permissions
After creating the repository, if you want to use it as a standalone server, you must configure user permissions. Here you need to use three files: svnserve.conf, authz, and passwd.
svnserve.conf
Use vim to open the svnserve.conf file and modify the following items.
anon-access = read //remove the leading #
auth-access = write //remove the leading #
password-db = passwd //remove the leading # the default is password, this file can be customized
authz-db = authz //remove the leading # the default is authz, this file can be customized
Save and exit
passwd
The purpose of this file is to set the user and password that can access the service. The users in this file can access the SVN service. Add the following content to this file
[users]
svnuser = svnuser123
After saving and exiting, we set a user svnuser who can access the service, and its password is svnuser123
authz
This file verifies the user's permissions on the corresponding directory. We add the following content at the end of the file
[/]
svnuser = rw
svnuser has read and write permissions for the entire root directory of the SVN service.
After editing the above three files, start using the service.
Start SVN service
Next, we start to start the SVN service. There are two types of services here: one is a single warehouse and the other is multiple warehouses.
Single warehouse
The service for a single repository is actually very simple. Remember the directory /repos we created at the beginning to store the repository? Here we created a new svntest repository in this directory. If it is a single repository, we only need to connect the repository name after /repos when starting the service - /repos/svntest
# svnserve –d –r /repos/svntest
After executing the above command, we will start the SVN service.
For this single warehouse access form, you can use the following command
# svn checkout svn://ip –username svnuser –password svnuser123 /target directory
In this way, what we check out is the contents of the svntest warehouse.
Multiple warehouses
The way to start a service with multiple repositories is actually not much different from the way to start a service with a single repository. The main difference is that we start by creating a new directory /repos to store the repositories. In this way, we don't need to add the directory name when starting the service. Just use /repos
# svnserve –d –r /repos
After the service is enabled, the access method changes
# svn checkout svn://ip/svntest –username svnuser –password svnuser123
When accessing, you need to add the svntest repository name after the svn address.
Of course, if we just want to save the code we developed, we have already completed it here. But sometimes we need to synchronize the code we submitted to the web directory. In this case, we also need to use the SVN hook post-commit to achieve our needs.
Post-commit synchronization code
First, we need to define the directory of our application project. Here we use /web as the directory of our web application project.
Then we go into the /web directory and check out a copy of the code from the repository.
# cd /web
# svn checkout svn://ip/svntest –username svnuser –password svnuser123
//Here we assume that multiple repositories are used
Next, edit the shell script post-commit.
# vim /repos/svntest/hooks/post-commit
Add the following script to the opened post-commit editing interface
#!/bin/bash
export LANG=zh_CN.UTF-8 #File encoding
REPOS="$1" #Warehouse path
REV="$2" #Version number of the code just submitted
SVN=/usr/bin/svn # svn command
WEB=/web/svntest # web directory
LOG=/data/home/auto_svn.log #Log file
$SVN update $WEB --username react --password react123 #Last updated command
Save and exit. Then modify the user permissions for post-commit. Give the user the permission to execute it.
# chmod u+x /repos/svntest/hooks/post-commit
Finally restart the SVN service
# ps –ef | grep svn //First, detect the current process id
root 4888 1 0 Mar25 ? 00:00:00 svnserve -d -r /repos
# kill -9 4888 //4888 is the process id. Use the kill command to kill the process.
# svnserve –d –r /repos //Restart the service
# ps –ef | grep svn
root 17957 1 0 19:38 ? 00:00:00 svnserve -d -r /repos
//The service has been started successfully, and its process id is 17957
At this time, when we submit new or modified code, the code will be automatically synchronized to the /web/svntest directory.
But there is a problem with this, that is, there will be a .svn directory in the /web/svntest directory. This poses a hidden danger to web security. Of course, such a problem can be eliminated through the rewrite function of nginx or apache. We can check the specific implementation by ourselves.
I hope the above simple process of building the SVN service will be helpful to you in your actual work.
For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.
Related Articles
What multipart/form-data does in post Upload upload files
Publish Date:2025/03/18 Views:63 Category:NETWORK
-
Everyone has used the attribute enctype="multipart/form-data" when uploading files using a form. What is the role of multipart/form-data? Let's talk about this topic. First, let's look at a case Look at the first code form action= "handl
About application/x-www-form-urlencoded
Publish Date:2025/03/18 Views:147 Category:NETWORK
-
As a data format of form, application/x-www-form-urlencoded has its own characteristics form action= "handle.php" method= "post" input type= "text" name= " uname" class= " uname" /br / input type= "text" name= "email" class=
My understanding of webservice is this
Publish Date:2025/03/18 Views:147 Category:NETWORK
-
Recently, I encountered such a project at work (temporarily named Project A). Project A itself was developed in PHP, but its data came from another project developed in Java (temporarily named Project B). Project A could not operate the dat
WSDL looks like this
Publish Date:2025/03/18 Views:190 Category:NETWORK
-
When I first started learning Webservice, I found that there were quite a lot of knowledge points involved, and each point could be a school of its own. Especially when I saw WSDL, I looked up information for a long time, but I was still a
Which technology do you choose to implement the web chat room?
Publish Date:2025/03/18 Views:61 Category:NETWORK
-
With the rise of HTML5 Websockets, web chat applications are becoming more and more popular. Recently, I am working on a mobile web application, the core function of which is to implement web chat on the mobile phone. Of course, the functio
Implementing a group chat room using socket.io
Publish Date:2025/03/18 Views:65 Category:NETWORK
-
This article will share with you an example of using socket.io to realize the function of group chat. If you want to use socket.io, you must use nodejs to implement the server, so we need to install socket.io in nodejs Install socket.io How
Getting started with FastCGI
Publish Date:2025/03/18 Views:164 Category:NETWORK
-
In "First Contact with CGI", we mentioned the operating mechanisms of CGI and Server APIs, as well as their respective advantages and disadvantages. In this chapter, we will learn about FastCGI, which combines the advantages of CGI and Serv
How to Fix the “This Site Can’t Provide a Secure Connection” Error
Publish Date:2025/03/17 Views:164 Category:NETWORK
-
Nothing is more frustrating than receiving an error message that brings our work to a screeching halt—especially when security is involved. Seeing a “This Site Can’t Provide a Secure Connection” notification can be confusing and ala
9 Ways to Fix NET::ERR_CERT_AUTHORITY_INVALID Error
Publish Date:2025/03/17 Views:176 Category:NETWORK
-
Sometimes even after you have an SSL certificate installed on your website, your website’s users may encounter NET::ERR_CERT_AUTHORITY_INVALID an invalid certificate authority error. Despite the intimidating name, the invalid certificate