In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Before I set up a public network SVN Server,google for my colleagues in development, I found that the following article was the most detailed, so I wrote it down and retyped it.
By the way, according to my own experience, I add a few details and summary. The configuration of this article is based on CentOS 5.x, but it also applies to other Linux distributions!
Subversion (svn for short) is a rising version management software in recent years, and is the successor to cvs.
At present, the vast majority of open source software use svn as code version management software. Subversion supports linux and windows, but it is mostly installed under linux
Svn servers can be run in two ways: stand-alone servers and with the help of apache. Svn:// or http://
Svn client tortoisesvn
The basic working principle of SVN:
Set up a source code library on a server that can store source programs for many different projects. The administrator of the source code base manages these source programs uniformly. Before using the source code base, each user must first download the source code library project file locally, then the developer can modify it locally, then submit it with the svn command on the left, and uniformly manage the modification of the tourist source code base.
Problems solved by version control:
* Code management confusion
* difficulties in resolving code conflicts
* raise a bug during code integration
* unable to control the owner of the code
* difficulties in releasing different versions of the project
Schematic diagram of how SVN works:
Subversion directory description:
* dav directory: provides directories for apache and mod_dav_svn to store internal data
* db directory: all version-controlled data storage files
* hooks directory: the directory where the hook script files are placed
* locks directory: the directory used to place subversion's hard-locked data, and to track clients accessing the vault
* format file: it is a text file with only an integer in it. Represents the version number of the current vault configuration
* conf directory: is the configuration file of this warehouse (user access account, permissions, etc.)
SVN Server detailed configuration manual
System environment
CentOS 5.8minimize installation (close iptables and selinux) + ssh + yum
First, install the necessary software packages
Yum install subversion mysql-server httpd mod_dav_svn mod_perl sendmail wget gcc-c++ make unzip perl* ntsysv vim-enhanced
Description:
Subversion (SVN server)
Mysql-server (for codestriker)
Httpd mod_dav_svn mod_perl (used to support WEB management of SVN servers)
Sendmail (used to configure email reminders after the user submits the code)
Wget gcc-c++ make unzip perl* (must-have package)
Ntsysv vim-enhanced (optional)
Second, basic SVN server configuration
1. Create a new directory to store all SVN files
# mkdir / home/svn
2. Create a new version repository
# svnadmin create / home/svn/project
3. Initialize the directory in the version repository
# mkdir project project/server project/client project/test (create a temporary directory)
# svn import project/ file:///home/svn/project-m "initialize SVN directory"
# rm-rf project (delete temporarily established directories)
4, add users
Adding SVN users is as simple as adding an entry in the / home/svn/project/conf/passwd file that looks like "username=password". For testing, I added the following:
[users]
# harry = harryssecret
# sally = sallyssecret
Pm = pm_pw
Server_group = server_pw
Client_group = client_pw
Test_group = test_pw
5. Modify user access policy
/ home/svn/project/conf/authz records the user's access policy. The following is a reference:
[groups]
Project_p = pm
Project_s = server1,server2,server3
Project_c = client1,client2,client3
Project_t = test1,test1,test1
[project:/]
@ project_p = rw
* =
[project:/server]
@ project_p = rw
@ project_s = rw
* =
[project:/client]
@ project_p = rw
@ project_c = rw
* =
[project:/doc]
@ project_p = rw
@ project_s = r
@ project_c = r
@ project_t = r
* =
Note: the above information indicates that only the project_p user group has the right to read and write the root directory. R indicates read access to the directory, w indicates write access to the directory, and rw indicates read and write permission to the directory. The * = on the last line indicates that no one is allowed to access this directory except for the user group with permissions set above. This is very important, it must be added!
6, modify the svnserve.conf file to improve the efficiency of user and policy configuration.
The svnserve.conf content is as follows:
[general]
Anon-access = none
Auth-access = write
Password-db = / home/svn/project/conf/passwd
Authz-db = / home/svn/project/conf/authz
7, start the server
# svnserve-d-r / home/svn
Note: if you modify the svn configuration, you need to restart the svn service as follows:
# ps-aux | grep svnserve
# kill-9 ID number
# svnserve-d-r / home/svn
8, test the server
# svn co svn://192.168.60.10/project
Authentication realm: 92731041-2dae-4c23-97fd-9e1ed7f0d18d
Password for 'root':
Authentication realm: 92731041-2dae-4c23-97fd-9e1ed7f0d18d
Username: server_group
Password for 'server_group':
Svn: Authorization failed (server_group does not use access to the root directory)
# svn co svn://192.168.60.10/project
Authentication realm: 92731041-2dae-4c23-97fd-9e1ed7f0d18d
Password for 'root':
Authentication realm: 92731041-2dae-4c23-97fd-9e1ed7f0d18d
Username: pm
Password for 'pm':
A project/test
A project/server
A project/client
Checked out revision 1. (test extraction succeeded)
# cd project/server
# vim main.c
# svn add main.c
# svn commit main.c-m "Test my C program, what are you looking at, no?"
Adding main.c
Transmitting file data.
Committed revision 2. (test submitted successfully)
Third, configure HTTP support for SVN server
1. Change the password of the SVN server
Because the password of the SVN server is in clear text, the HTTP server does not support
So you need to convert it to a format supported by HTTP. I wrote a Perl script to finish the job.
The script reads as follows:
# cd / home/svn/project/conf/
# vim PtoWP.pl
#! / usr/bin/perl
# write by huabo, 2009-11-20
Use warnings
Use strict
# open the svn passwd file
Open (FILE, "passwd") or die ("Cannot open the passwd fileboxes!\ n")
# clear the apache passwd file
Open (OUT_FILE, "> webpasswd") or die ("Cannot open the webpasswd fileboxes!\ n")
Close (OUT_FILE)
# begin
Foreach () {
If ($_ = ~ m / ^ [^ #]. * = /) {
$_ = ~ splash /
`htpasswd-b webpasswd $_ `
}
}
# chmod + x PtoWP.pl
#. / PtoWP.pl
Adding password for user pm
Adding password for user server_group
Adding password for user client_group
Adding password for user test_group
Now there will be one more webpasswd file in the directory.
2. Modify httpd.conf and add content about SVN server
Edit / etc/httpd/conf/httpd.conf and add the following information at the end:
DAV svn
SVNPath / home/svn/project/
AuthType Basic
AuthName "svn for project"
AuthUserFile / home/svn/project/conf/webpasswd
AuthzSVNAccessFile / home/svn/project/conf/authz
Satisfy all
Require valid-user
3. Change the owner of svn directory to apache account:
Chown-R apache.apache / home/svn/project/
Note: if this step is missing in the original text, there will be permission problems.
4. Restart the Web server:
# / etc/init.d/httpd restart
Stopping httpd: [FAILED]
Starting httpd: [OK]
5. Access the http://192.168.60.10/project/server/ test with a browser
The test results are shown in the following figure:
(test successful)
Fourth, configure email reminder support
1, install the Perl module Module::Build
# wget http://search.cpan.org/CPAN/authors/id/D/DA/DAGOLDEN/Module-Build-0.36_11.tar.gz
# tar xvf Module-Build-0.36_11.tar.gz
# cd Module-Build-0.36_11
# perl Build.PL
#. / Build
#. / Build test
#. / Build install
# cd..
2. Install the Perl module Authen::SASL
# wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/Authen-SASL-2.15.tar.gz
# tar xvf Authen-SASL-2.15.tar.gz
# cd Authen-SASL-2.15
# perl Makefile.PL
# make test
# make install
# cd..
3. Install Perl module Net::SMTP_auth
# wget http://search.cpan.org/CPAN/authors/id/A/AP/APLEINER/Net-SMTP_auth-0.08.tar.gz
# tar xvf Net-SMTP_auth-0.08.tar.gz
# cd Net-SMTP_auth-0.08
# perl Makefile.PL
# make test
# make install
# cd..
4. Install the Perl module SVN::Notify
# wget http://search.cpan.org/CPAN/authors/id/D/DW/DWHEELER/SVN-Notify-2.80.tar.gz
# tar xvf SVN-Notify-2.80.tar.gz
# cd SVN-Notify-2.80
# perl Build.PL
#. / Build
#. / Build test
#. / Build install
# cd..
5. Start the mail server
# service sendmail restart
Shutting down sendmail: [FAILED]
Starting sendmail: [OK]
Starting sm-client: [OK]
6. Configure automatic email script
Modify the post-commit script to support mail notification.
# cd / home/svn/project/hooks/
# vim post-commit
The contents are as follows:
#! / bin/sh
REPOS= "$1"
REV= "$2"
/ usr/bin/svnnotify-repos-path "$1"-revision "$2"-to caodaijun@pica.com-from caodaijun@feinno.com-handler "HTML::ColorDiff"-with-diff-smtp localhost-smtp-user root-smtp-pass 5201314318-c "UTF-8"-g zh_CN-o raw-svnlook / usr/bin/svnlook-subject-prefix'[SVN Update]'
(the to parameter represents the address to receive email, which can be multiple, which is important when you have multiple bosses,:). The from parameter is virtual and represents your sending address. In general, this parameter is not important, but if the recipient's mail server has anti-spam function and needs to determine the source address, whether this parameter is legal or not is very important.
Then add executable permissions to the script
# chmod + x post-commit
7. When you submit it again, you will send a letter to the specified email address.
As shown in the following figure:
Fifth, other commonly used configurations
1. Force writing log script
Configure the pre-commit file, requiring the user to write log.
# cd / home/svn/project/hooks/
# vim pre-commit
The contents of the document are as follows:
#! / bin/sh
REPOS= "$1"
TXN= "$2"
SVNLOOK=/usr/bin/svnlook
LOGMSG= `$SVNLOOK log-t "$TXN"$REPOS" | grep "[a-zA-Z0-9]" | wc-c`
If ["$LOGMSG"-lt 5 (required log length, modified as needed)]
Then
Echo-e "\ nEmpty log message not allowed. Commit aborted!" 1 > & 2
Exit 1
Fi
After the configuration is completed, add executable permissions to this piece. When you submit the code again, you must write comments as required,:)
2, the log script can be modified
Configure the pre-revprop-change file, which will run when you modify the log in show log, and get the permission to modify it, otherwise it will report an error: DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existent. At least one property change failed; repository is unchanged
# cd / home/svn/project/hooks/
# vim pre-revprop-change
The contents of the document are as follows:
REPOS= "$1"
REV= "$2"
USER= "$3"
PROPNAME= "$4"
If ["$PROPNAME" = "svn:log"]; then exit 0 fi
Exit 1
Add executable permissions to improve efficiency after configuration.
6. Backup management
Regular backup of the svn server is very important. The easiest way is to back up the warehouse directory regularly.
1. Create a new backup directory
# mkdir / opt/project_backup
2. Write backup scripts
# cd / home/svn/
# vim project_backup.sh
The contents are as follows:
#! / bin/bash
# write by huabo, 2009-11-20
Cd / home/svn
Now= `/ bin/date +% Y% m% d`
/ bin/tar czvf "project_backup_$now.tar.gz" project/ & & rm-rf / opt/project_backup/* & & / bin/mv project_backup_*.tar.gz / opt/project_backup/
If [$? = = 0]
Then
Result= "Oklahs!"
Else
Result= "falsehood!"
Fi
# send mail to administrator
/ bin/mail caodaijun@pica.com-s "project_backup_$now"
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.