[SCM] source code management-SVN + Apache

Source: Internet
Author: User
Tags builtin fully qualified domain name

Transferred from:

 

Http://www.cnblogs.com/andgame/archive/2010/10/17/1853733.htmlhttp://www.cnblogs.com/selfly/archive/2011/01/14/1935715.html

Install SVN + Apache + permission control in Linux

I. Related versions
When installing the subversion, you must ensure that the version of the software is consistent, rather than the latest version. The following is the version of the software I installed.
Httpd-2.2.3.tar.gz
Subversion-deps-1.4.0.tar.gz
Subversion-1.4.0.tar.gz

Ii. Installation preparation
# Mkdir/Subversion
# Cp httpd-2.2.3.tar.gz/subversion/
# Cp subversion-deps-1.4.0.tar.gz/subversion/
# Cp subversion-1.4.0.tar.gz/subversion/
# Cd/subversion/
# Tar zxvf httpd-2.2.3.tar.gz
# Tar zxvf subversion-deps-1.4.0.tar.gz
# Tar zxvf subversion-1.4.0.tar.gz

In this step, if it is a 32-bit Linux system, you can directly install httpd. If it is a 64-bit Linux system, perform the following operations to re-compile:
1. Delete the configure file under the installation directory, in my environment is the httpd-2.2.6/configure
2. Delete httpd-2.26/srclib/APR-util/configure"
3. Run the following command to recreate the compilation file (the following command runs under the http-2.26/directory ).
#./Buildconf
After rebuilding the compilation file, you can now have a 64-bit Apr-util.

Iii. httpd Installation.
# Cd/subversion/httpd-2.2.3
#./Configure -- enable-Dav -- enable-so -- prefix =/usr/local/apache2/-- enable-maintainer-Mode

(Note that the parameters of the preceding commands cannot be reduced at will; otherwise, some unknown errors may occur.
If the preceding 64-bit Linux File is compiled, run the following command:
#./Configure -- enable-Dav -- enable-so -- prefix =/usr/local/apache2/-- enable-maintainer-mode -- With-expat = builtin
)

# Make
# Make install
# Cd/usr/local/apache2/bin/
#. /Apachectl start (this command may cause errors similar to cocould not reliably determine the server's fully qualified domain name, using 192.168.0.71 for servername. You don't need to worry about it, the Service has actually been started. The same is true for stopped and restarted services)
In this case, open the browser and enterHttp: // localhost/If it works appears in the browser, it indicates that httpd has been installed successfully.

4. Subversion Installation
# Cd/subversion-1.4.0
#. /Configure -- With-apxs =/usr/local/apache2/bin/apxs -- With-Apr =/usr/local/apache2/-- With-Apr-util =/usr/local /apache2/-- prefix =/usr/local/Subversion -- With-SSL -- With-zlib -- enable-maintianer-Mode
# Make & make install

(
If an error occurs: Make: *** [subversion/libsvn_ra_dav/libsvn_ra_dav-1.la] Error 1
Solution: add the-FPIC option to the front of the neon/src/makefie cflags file, for example, cflags =-FPIC-g-O2.
Make again
)

V. Create and import a version Library
[Root @ localhost subversion-1.4.0] # cd/usr/local/subversion/bin/
[Root @ localhost bin] # mkdir/Repository
[Root @ localhost bin] #./svnadmin create -- FS-type fsfs/Repository/test
[Root @ localhost bin] # ls/Repository/test/
// If the following content appears in LS/Repository/test/, the Subversion is successfully installed.
Conf Dav dB format hooks locks readme.txt

Import version Library
[Root @ localhost bin] #./SVN import/root/src/File: // repository/test/-M "Initial import"
// If the command is successfully executed, the following message is displayed ,.
Add/root/src/Main. cpp
The submitted revision is 1.

6. modify directory permissions
[Root @ localhost bin] # cd/Repository/test/
[Root @ localhost test] # chmod-r 777 *

7. Modify the Apache configuration file
1): Open The apache2/CONF/httpd. conf file.
2): Modify the httpd. conf file and add the following lines at the end of the file.
<Location/SVN>
Dav SVN
Svnparentpath/usr/local/subversion/Repository
</Location>
3): Save and exit

As specified above, SVN does not require permissions, that is, any anonymous user can access, modify, and submit
In actual use, permission control is required. Therefore, the configuration file must be configured as follows:

Go To The apache2/bin directory and create user groups and user files in other folders.

Create a user group file:
# Touch authz

Write the following content in the authz file:CodeNote that the user group Admin has four users: lyd, zzq, MC, and yhl. The Admin group has the read and write permissions on the root directory [/]. r indicates read w indicates write:

[Groups]
Admin = lyd, zzq, MC, yhl
[/]
@ Admin = RW

Create a user. The user here must be in the above user group to have the corresponding permissions:
Htpasswd-CM pwd.txt lyd is created for the first time. In addition, the-CM connector is used to create the User File pwd.txt. Of course, you can also use the alias or suffix name.

Htpasswd pwd.txt zzq is created for the second time. Because the user file has been created for the first time, you only need to add a user to the user file.

Modify the apache2/CONF/httpd. conf file, and add the following code at the end to specify the location of the svn repository and the file to be used for permission.

<Location/SVN>
Dav SVN
Svnparentpath/usr/local/subversion/Repository/
Authzsvnaccessfile/usr/local/apache2/bin/authz
Authtype basic
Authname "Subversion"
Authuserfile/usr/local/apache2/bin/pwd.txt
Require valid-user
</Location>

8. Restart the apache service.
[Root @ localhost bin] # cd/usr/local/apache2/bin/
[Root @ localhost bin] #./apachectl stop
[Root @ localhost bin] #./apachectl start
Or directly restart

Start SVN
/Usr/local/subversion/bin/svnserve-d-r/Repository

 

Install SVN + Apache + permission control in Windows

 1. Download the Apache server and subversion Binary Package (apache version 2.2.16 and subversion 1.6.13)
Apache: http://httpd.apache.org/download.cgi
SVN server: http://sourceforge.net/projects/win32svn/ (SVN server needs to download contains mod_dav_svn.so

And the version of the mod_authz_svn.so library file, Apache needs to use these two library files)
Subversion server-side list: http://subversion.apache.org/packages.html

 

2. Install the Apache server and decompress the Subversion binary file. Modify httpd. conf In the conf folder of the Apache server.
# Loadmodule dav_module modules/mod_dav.so
# Loadmodule dav_fs_module modules/mod_dav_fs.so
Remove the comments from the above two lines and add the following code to load the two library files in the subversion.
Loadmodule dav_svn_module "C: \ SVN \ svn-win32-1.6.13 \ bin \ mod_dav_svn.so"
Loadmodule authz_svn_module "C: \ SVN \ svn-win32-1.6.13 \ bin \ mod_authz_svn.so"
You can also copy the mod_dav_svn.so and mod_authz_svn.so library files to the modules directory of Apache for reference.
Loadmodule dav_svn_module modules/mod_dav_svn.so
Loadmodule authz_svn_module modules/mod_authz_svn.so

 

Add the following configuration at the end of the file
<Location/repos>
Dav SVN
Svnparentpath C:/repos # svnparentpath is used for multiple purposes in this folder. If there is only one project, you can use svnpath
Authtype basic
Authname "Subversion server"
Authuserfile "C: \ repos \ conf \ htpasswd" # The htpasswd file stores the encrypted file of the user name and password generated by the htpasswd that comes with Apache.

Authzsvnaccessfile "C: \ repos \ conf \ authz" # authz authorization file, which is written according to the conf/authz rules in the version Library

Require valid-user
</Location>

 

3. Use the htpasswd command to create a user
C: \ apache \ bin> htpasswd-CM c: \ repos \ conf \ htpasswd Admin
New Password :*
Re-type new password :*
Adding password for user admin
C: \ apache \ bin> htpasswd-m c: \ repos \ conf \ htpasswd user1
New Password :*
Re-type new password :*
Adding password for user user1
...

 

4. Create a version Library
Three version libraries are created in the repos folder.
C: \ SVN \ svn-win32-1.6.13 \ bin> svnadmin create c: \ repos \ repos1
C: \ SVN \ svn-win32-1.6.13 \ bin> svnadmin create c: \ repos \ repos2
C: \ SVN \ svn-win32-1.6.13 \ bin> svnadmin create c: \ repos \ repos3
The three version libraries share users and permission configuration files, so the configuration files in the conf folder of each version library are useless.

 

5.ConfigurationAuthz permission File
[Groups]
Admin = admin, user1
User = user3, user2

[/]
* =
Admin = RW

[Repos1:/]
@ Admin = RW

[Repos2:/]
@ Admin = RW

[Repos3:/]
@ Admin = RW

Restart the Apache server and use tsvn or web to access the server.

 

6. Modify the httpd. conf configuration to access the version library list.

Redirectmatch ^ (/repos) $1/

<Location/repos/>
Dav SVN
Svnparentpath C:/Repos
Svnlistparentpath on

Authtype basic
Authname "Subversion server"
Authuserfile "C: \ repos \ conf \ htpasswd"

Authzsvnaccessfile "C: \ repos \ conf \ authz"
Require valid-user
</Location>
Now, you can access the list of all version libraries through http: // 127.0.0.1/repos.

 

7. Modify the httpd. conf configuration so that you can use (Http: // 127.0.0.1/) Access the version Library

<Location/>
Dav SVN
Svnparentpath C:/Repos
Svnlistparentpath on
</Location>

 

<Locationmatch/. +>
# Note that this block does not contain configurations such as Dav SVN svnparentpath ..
Authtype basic
Authname "Subversion server"
Authuserfile "C: \ repos \ conf \ htpasswd"

Authzsvnaccessfile "C: \ repos \ conf \ authz"
Require valid-user
</Locationmatch>

 

 

Complete!

 

I. Related versions
When installing the subversion, you must ensure that the version of the software is consistent, rather than the latest version. The following is the version of the software I installed.
Httpd-2.2.3.tar.gz
Subversion-deps-1.4.0.tar.gz
Subversion-1.4.0.tar.gz

Ii. Installation preparation
# Mkdir/Subversion
# Cp httpd-2.2.3.tar.gz/subversion/
# Cp subversion-deps-1.4.0.tar.gz/subversion/
# Cp subversion-1.4.0.tar.gz/subversion/
# Cd/subversion/
# Tar zxvf httpd-2.2.3.tar.gz
# Tar zxvf subversion-deps-1.4.0.tar.gz
# Tar zxvf subversion-1.4.0.tar.gz

In this step, if it is a 32-bit Linux system, you can directly install httpd. If it is a 64-bit Linux system, perform the following operations to re-compile:
1. Delete the configure file under the installation directory, in my environment is the httpd-2.2.6/configure
2. Delete httpd-2.26/srclib/APR-util/configure"
3. Run the following command to recreate the compilation file (the following command runs under the http-2.26/directory ).
#./Buildconf
After rebuilding the compilation file, you can now have a 64-bit Apr-util.

Iii. httpd Installation.
# Cd/subversion/httpd-2.2.3
#./Configure -- enable-Dav -- enable-so -- prefix =/usr/local/apache2/-- enable-maintainer-Mode

(Note that the parameters of the preceding commands cannot be reduced at will; otherwise, some unknown errors may occur.
If the preceding 64-bit Linux File is compiled, run the following command:
#./Configure -- enable-Dav -- enable-so -- prefix =/usr/local/apache2/-- enable-maintainer-mode -- With-expat = builtin
)

# Make
# Make install
# Cd/usr/local/apache2/bin/
#. /Apachectl start (this command may cause errors similar to cocould not reliably determine the server's fully qualified domain name, using 192.168.0.71 for servername. You don't need to worry about it, the Service has actually been started. The same is true for stopped and restarted services)
In this case, open the browser and enterHttp: // localhost/If it works appears in the browser, it indicates that httpd has been installed successfully.

4. Subversion Installation
# Cd/subversion-1.4.0
#. /Configure -- With-apxs =/usr/local/apache2/bin/apxs -- With-Apr =/usr/local/apache2/-- With-Apr-util =/usr/local /apache2/-- prefix =/usr/local/Subversion -- With-SSL -- With-zlib -- enable-maintianer-Mode
# Make & make install

(
If an error occurs: Make: *** [subversion/libsvn_ra_dav/libsvn_ra_dav-1.la] Error 1
Solution: add the-FPIC option to the front of the neon/src/makefie cflags file, for example, cflags =-FPIC-g-O2.
Make again
)

V. Create and import a version Library
[Root @ localhost subversion-1.4.0] # cd/usr/local/subversion/bin/
[Root @ localhost bin] # mkdir/Repository
[Root @ localhost bin] #./svnadmin create -- FS-type fsfs/Repository/test
[Root @ localhost bin] # ls/Repository/test/
// If the following content appears in LS/Repository/test/, the Subversion is successfully installed.
Conf Dav dB format hooks locks readme.txt

Import version Library
[Root @ localhost bin] #./SVN import/root/src/File: // repository/test/-M "Initial import"
// If the command is successfully executed, the following message is displayed ,.
Add/root/src/Main. cpp
The submitted revision is 1.

6. modify directory permissions
[Root @ localhost bin] # cd/Repository/test/
[Root @ localhost test] # chmod-r 777 *

7. Modify the Apache configuration file
1): Open The apache2/CONF/httpd. conf file.
2): Modify the httpd. conf file and add the following lines at the end of the file.
<Location/SVN>
Dav SVN
Svnparentpath/usr/local/subversion/Repository
</Location>
3): Save and exit

As specified above, SVN does not require permissions, that is, any anonymous user can access, modify, and submit
In actual use, permission control is required. Therefore, the configuration file must be configured as follows:

Go To The apache2/bin directory and create user groups and user files in other folders.

Create a user group file:
# Touch authz

Write the following content in the authz file. The following Code indicates that the user group Admin has four users: lyd, zzq, MC, and yhl, for the Admin group, [/] indicates that the root directory has read and write permissions. r indicates read w indicates write:

[Groups]
Admin = lyd, zzq, MC, yhl
[/]
@ Admin = RW

Create a user. The user here must be in the above user group to have the corresponding permissions:
Htpasswd-CM pwd.txt lyd is created for the first time. In addition, the-CM connector is used to create the User File pwd.txt. Of course, you can also use the alias or suffix name.

Htpasswd pwd.txt zzq is created for the second time. Because the user file has been created for the first time, you only need to add a user to the user file.

Modify the apache2/CONF/httpd. conf file, and add the following code at the end to specify the location of the svn repository and the file to be used for permission.

<Location/SVN>
Dav SVN
Svnparentpath/usr/local/subversion/Repository/
Authzsvnaccessfile/usr/local/apache2/bin/authz
Authtype basic
Authname "Subversion"
Authuserfile/usr/local/apache2/bin/pwd.txt
Require valid-user
</Location>

8. Restart the apache service.
[Root @ localhost bin] # cd/usr/local/apache2/bin/
[Root @ localhost bin] #./apachectl stop
[Root @ localhost bin] #./apachectl start
Or directly restart

Start SVN
/Usr/local/subversion/bin/svnserve-d-r/Repository

 

Install SVN + Apache + permission control in Windows

 1. Download the Apache server and subversion Binary Package (apache version 2.2.16 and subversion 1.6.13)
Apache: http://httpd.apache.org/download.cgi
SVN server: http://sourceforge.net/projects/win32svn/ (SVN server needs to download contains mod_dav_svn.so

And the version of the mod_authz_svn.so library file, Apache needs to use these two library files)
Subversion server-side list: http://subversion.apache.org/packages.html

 

2. Install the Apache server and decompress the Subversion binary file. Modify httpd. conf In the conf folder of the Apache server.
# Loadmodule dav_module modules/mod_dav.so
# Loadmodule dav_fs_module modules/mod_dav_fs.so
Remove the comments from the above two lines and add the following code to load the two library files in the subversion.
Loadmodule dav_svn_module "C: \ SVN \ svn-win32-1.6.13 \ bin \ mod_dav_svn.so"
Loadmodule authz_svn_module "C: \ SVN \ svn-win32-1.6.13 \ bin \ mod_authz_svn.so"
You can also copy the mod_dav_svn.so and mod_authz_svn.so library files to the modules directory of Apache for reference.
Loadmodule dav_svn_module modules/mod_dav_svn.so
Loadmodule authz_svn_module modules/mod_authz_svn.so

 

Add the following configuration at the end of the file
<Location/repos>
Dav SVN
Svnparentpath C:/repos # svnparentpath is used for multiple purposes in this folder. If there is only one project, you can use svnpath
Authtype basic
Authname "Subversion server"
Authuserfile "C: \ repos \ conf \ htpasswd" # The htpasswd file stores the encrypted file of the user name and password generated by the htpasswd that comes with Apache.

Authzsvnaccessfile "C: \ repos \ conf \ authz" # authz authorization file, which is written according to the conf/authz rules in the version Library

Require valid-user
</Location>

 

3. Use the htpasswd command to create a user
C: \ apache \ bin> htpasswd-CM c: \ repos \ conf \ htpasswd Admin
New Password :*
Re-type new password :*
Adding password for user admin
C: \ apache \ bin> htpasswd-m c: \ repos \ conf \ htpasswd user1
New Password :*
Re-type new password :*
Adding password for user user1
...

 

4. Create a version Library
Three version libraries are created in the repos folder.
C: \ SVN \ svn-win32-1.6.13 \ bin> svnadmin create c: \ repos \ repos1
C: \ SVN \ svn-win32-1.6.13 \ bin> svnadmin create c: \ repos \ repos2
C: \ SVN \ svn-win32-1.6.13 \ bin> svnadmin create c: \ repos \ repos3
The three version libraries share users and permission configuration files, so the configuration files in the conf folder of each version library are useless.

 

5.ConfigurationAuthz permission File
[Groups]
Admin = admin, user1
User = user3, user2

[/]
* =
Admin = RW

[Repos1:/]
@ Admin = RW

[Repos2:/]
@ Admin = RW

[Repos3:/]
@ Admin = RW

Restart the Apache server and use tsvn or web to access the server.

 

6. Modify the httpd. conf configuration to access the version library list.

Redirectmatch ^ (/repos) $1/

<Location/repos/>
Dav SVN
Svnparentpath C:/Repos
Svnlistparentpath on

Authtype basic
Authname "Subversion server"
Authuserfile "C: \ repos \ conf \ htpasswd"

Authzsvnaccessfile "C: \ repos \ conf \ authz"
Require valid-user
</Location>
Now, you can access the list of all version libraries through http: // 127.0.0.1/repos.

 

7. Modify the httpd. conf configuration so that you can use (Http: // 127.0.0.1/) Access the version Library

<Location/>
Dav SVN
Svnparentpath C:/Repos
Svnlistparentpath on
</Location>

 

<Locationmatch/. +>
# Note that this block does not contain configurations such as Dav SVN svnparentpath ..
Authtype basic
Authname "Subversion server"
Authuserfile "C: \ repos \ conf \ htpasswd"

Authzsvnaccessfile "C: \ repos \ conf \ authz"
Require valid-user
</Locationmatch>

 

 

Complete!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.