The svn server deployment in this article mainly refers to the deployment. This article describes how to deploy services on Ubuntu through SVN. Because the implementation and use of the Apache service module are different, the solution in this article is only applicable to ubuntu.
The svn server deployment in this article mainly refer to the http://www.linuxidc.com/Linux/2012-07/66234.htm, which is not very clear do some annotations, and mainly realize the setting of multiple version libraries, and each version library needs to be verified by the user, each program has a version library.
This article describes how to deploy services on Ubuntu through SVN. Because the implementation and use of the Apache service module are different, the solution in this article is only applicable to ubuntu. If you are in another environment, deploy it as appropriate.
This article describes how to access the SVN server through http when submitting code, use Mysql for user authentication, and automatically deploy it to the server after submission.
The main steps are as follows:
1. install Apache and Mysql:
Run
- $ Sudo apt-get install apache2 mysql-server
Run
- $ Sudo/etc/init. d/apache2 start
Access http: // 127.0.0.1 to test whether apache is installed successfully. In case of port conflict, it may be because other web servers (such as Nginx) have occupied port 80. You can modify the corresponding configuration file and use another port.
2. Install subversion and the corresponding Apache server module and MySQL user authentication management module:
- $ Sudo apt-get install subversion libapache2-svnlibapache2-mod-auth-mysql
- $ Sudo a2enmod auth_mysql
3. Create a subversion project and version Library
All version libraries can be placed in a directory, such as/var/www/svn, which can be customized.
- $ Sudo mkdir/var/www/svn
You can then create two version libraries, such as/var/www/svn/repos and/var/www/svn/repos1.
Create two folders first
- $ Sudo mkdir/var/www/svn/repos
- $ Sudo mkdir/var/www/svn/repos1
Run the svnadmin command to create two repositories. Note that -- fs-type is used to specify the fsfs version library. By default, the Berkeley DB version library is created.
- $ Sudo svnadmin create/var/www/svn/repos -- fs-type fsfs
- $ Sudo svnadmin create/var/www/svn/repos1 -- fs-type fsfs
Finally, grant the www-data user the read and write permissions for these version libraries, because the folder needs to be read and written during deployment through the apache server.
- $ Sudo chown-Rwww-data/home/www/svn/repos
- $ Sudo chown-Rwww-data/home/www/svn/repos1
4. Create a user verification database
Create a database for User Authentication
- $ Mysql-u root-p
- # Create a database for User Authentication
- Mysql> create datebase svn;
- # Use this database
- Mysql> USE svn;
- # Create a user table, which contains the name, password, and groups columns and is named as the primary key.
- Mysql> create table user (
- Name char (30) NOT NULL COMMENT'Username',
- Passwd char (32) NOT NULL COMMENT'Password',
- Groups varchar (32) Not null comment 'group ',
- Primary key (name) ENGINE = InnoDB default charset = utf8;
- Mysql> insert into user VALUE ('Admin', MD5 ('Admin'), 'Admin ');
- Mysql> insert into user VALUE ('Test', MD5 ('Test'), 'Test ');
Note the following:
The password field must be sufficiently wide. This document uses the MD5 password (32 bytes). If SHA1 is used, 40 bytes are required.
You must set the groups field, which can be the user name by default. This ensures that you can specify a group in the apache configuration file when using mysql for user authentication, only a specific group can access the code library to prevent access by other users.