svn server configuration under windows

Preparations

First , download the Windows version of the SVN server (you will use search engines, so no download address will be provided), here I take the ZIP decompression version of svn-win32-1.4.3 as an example, and decompress it to the target directory. , For example, I decompressed it to the Subversion directory under the D drive, and added D:\Subversion\bin to the system environment variable. If your decompression location is different from mine, please set the environment variable according to your actual path.

Step 1: Create SVN database

Open the Windows command prompt and execute the command svnadmin create F:\SVN, svnadmin create is the command to create the SVN database, F:\SVN is the location of your SVN database, here I just give an example, you You can decide the location of the SVN database by yourself. After executing the above command, there will be an additional SVN directory under the F drive, which contains several directories and files. The conf directory is used to store the permission configuration, which will be described in detail later. The dav directory is used for Provided to apache and mod_dav_svn to store internal data, the db directory is all version-controlled data files, the hooks directory is used to place hook script files, and the locks directory is used to store Subversion file library lock data, used to track clients accessing the file library. The format is A text file with only an integer in it, which represents the version number of the current file library configuration, and a readme.txt. Needless to say, you know what it is for.

Step 2: Start the SVN server

Continue to execute the command svnserve -d -r F:\SVN in the Windows command prompt, the parameter -d is to use the SVN service as a background service, and the parameter -r is to specify the root directory location of the SVN service. F:\SVN is naturally the SVN root directory, so far the SVN server has been started, you can test it with the SVN client.

Step 3: Register the SVN service as a system service

You may ask, don't you have to enter a command every time you start the SVN server? How to make the SVN server start automatically when it is turned on? The answer is to register the SVN service with the Windows system service and execute the command in the Windows command prompt
sc create SVN binpath= "\"d:\subversion\bin\svnserve.exe\" --service -r F:\SVN" displayname= "SVN Service" depend= Tcpip start= auto, note that after the "=" sign There is a space. Is this command a bit long? In fact, it is easy to understand. sc is a system service registration tool that comes with Windows. The Microsoft Support Center provides detailed instructions. I will not repeat it here. The parameter binpath= "\"d:\subversion \bin\svnserve.exe\" --service -r F:\SVN" is similar to the command we used to manually start the SVN server earlier? Just change -d to --service, which is not difficult to understand, because now it is service. Well, now you're done, try it again.
PS: If you want to delete the SVN service just registered from the system service, you can use the sc delete SVN command.

Step 4: Set Permissions

You all work in IT. I don't need to say how important it is to set reasonable permissions for the projects under development. Take the development of games as an example. The program department needs to have all the permissions of the source code directory, as well as the art resource directory and planning. The art department needs to have all the permissions of the art resource directory and the acquisition permission of the planning case directory, while the planning department needs to have all the permissions of the planning case directory and the acquisition permission of the art resource directory. Next, let's take a look at how SVN sets permissions. Remember the conf directory mentioned when creating the SVN database in the first step. There are 3 files in the conf directory. These 3 files are text files, which can be opened with a notepad. They are on the line, let's look at the svnserve.conf file first, the anon-access item specifies the operation permissions that unauthenticated users have. It has 3 valid values, namely read, write, none, read is read permission, write For write permission, none means no permission, the password-db item is used to specify the file that stores the user name and password, the authz-db item is used to specify the file that stores user permissions, and the realm item is used to specify the verification scope. If it is not used, the above 4 items are all commented out by default. The # sign is a comment symbol, and you only need to remove the comment symbol to use them. The passwd file is the file that stores the user name and password by default. For example, I set up a Sol user with a password of 111111. Just add Sol=111111 under [users]. The authz file is the default file to store user permissions, [groups] Represents a group, here we set up a developer group, and divide the Sol user created earlier into the developer group, also just write developer=Sol under [groups], [/] represents the root directory, if we want to set the developer If the group has full access rights, add @developer=rw below, and add the @ character in front to represent the group. In addition, we allow everyone to have read access and add *=r below. SVN allows each To set permissions for each directory, the setting method is similar to that of the root directory. If you still don't understand it well, please see the following example.

An example of permission configuration

Let's take game project development as an example, the project name is called Project1, how to create an SVN database has been mentioned above, we create a local database named Project1 in the root directory of SVN, first configure svnserve.conf in the conf directory file, we do not allow anyone unrelated to R&D to access this project, so we prohibit anonymous access and create a personal account for each R&D staff. The permission file and account information file can use the default authz file and passwd file in the same directory.

The svnserve.conf file is configured as follows:

[general]
anon-access = none
password-db = passwd
authz-db = authz
If authentication is not required, you can comment out the sentence authz-db = authz
Next , configure the passwd file for each Each R&D staff set up a personal account, assuming that the project leader is Sol, the program department has Tom, Mark, the art department has John, Alina, Candice, Ellen, and the planning department has Terry, Jane, here we set all the passwords to 000000 for convenience. It doesn't matter if it is an example now, the password cannot be set so casually in practical application.

The passwd file is configured as follows:

[users]
Sol = 000000
Tom = 000000
Mark = 000000
John = 000000
Alina = 000000
Candice = 000000
Ellen = 000000
Terry = 000000
Jane = 000000

accounts are created, now assign different permissions to them, first set up 4 groups. They are manager, developer, artist, designer, assign Sol to the manager group, and assign Tom and Mark to the developer group. Assign John, Alina, Candice, Ellen to the artist group, Terry, Jane to the designer group, etc. We will create four directories of designs, sources, resources, reports in the project, and then in the reports directory for each person Create a directory named after your own account to put everyone's work reports. The manager group has read and write permissions to all directories, the developer group has read and write permissions to the sources directory and read permissions to the designs and resources directories, and the artist group has resources. The read and write permissions of the directories and the read permissions of the designs directory. The designer group has the read and write permissions of the designs directory and the read permissions of the resources directory. Each account has the read and write permissions of the directory named after its own account in the reports directory. That is to say, everyone's work report can only be seen by themselves and the project leader.

The authz file is configured as follows:

[groups]
manager = Sol
developer = Tom,Mark
artist = John,Alina,Candice,Ellen
designer = Terry,Jane

[Project1:/]
@manager = rw
* = r

[Project1:/designs]
@manager = rw
@developer = r
@artist = r
@designer = rw
* =  

[Project1:/sources]
@manager = rw
@developer = rw
* =

[Project1:/resources]
@manager = rw
@developer = r
@artist = rw
@designer = r
* =

[Project1:/reports/Sol]
Sol = rw
* =

[Project1:/reports/Tom]
@manager = rw
Tom = rw
* =

[Project1:/reports/Mark]
@manager = rw
Mark = rw
* =

[Project1:/reports/John]
@manager = rw
John = rw
* =

[Project1:/reports/Alina]
@manager = rw
Alina = rw
* =

[Project1:/reports/Candice]
@manager = rw
Candice = rw
* =

[Project1:/reports/Ellen]
@manager = rw
Ellen = rw
* =

[Project1:/reports/Terry]
@manager = rw
Terry = rw
* =

[Project1:/reports/Jane]
@manager = rw
Jane = rw
* =

The permissions of the directory are all set, but we have not created the directory, and now only the project leader has permission to create it in the project root directory directory, so we use Sol's account to create the four directories of designs, reports, resources, and sources, and then go to the reports directory to create a work report directory named after each account for each person. Well, it's all done here. ,knock off.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326488206&siteId=291194637