Developers learn Linux (8): CentOS7 Compile and install Subversion1.9.5 and Apache2.4.25 and integrate

Source: Internet
Author: User
Tags md5 hash nginx reverse proxy tortoisesvn

1. Preface
This article will show you how to compile and install SVN server-side management software subverion and Web server Apache. Originally in the previous series has been said to use Nginx as a Web server, so I have been looking for information about subverion integrated Nginx, in this process found the Nginx author Igor Sysoev in answer to other people's similar problems, the URL is http. Mailman.nginx.org/pipermail/nginx/2007-january/000504.html, but according to Igor Sysoev's answer did not succeed, so still back to Apache integration with SVN, Then through the Nginx reverse proxy to Apache approach. Version control could have been done directly by installing subversion, but there were some issues, such as the fact that the password was saved to the file in plaintext, so the Apache integrated Nginx method was used.
2. Preparation
This article focuses on compiling and configuring Subversion and Apache (ie, httpd), but since compiling the two software relies on other class libraries, the following 7 files are required in order to complete the subverion1.9.5 and httpd2.4.25 compilation installations, i.e. Apr, Apr-util, SCons, serf, Sqlite-amalgamation, httpd, and subversion.
We log into the system as root and download it through wget to the/root directory.
Subversion-1.9.5:wget http://mirrors.hust.edu.cn/apache/subversion/subversion-1.9.5.tar.gz
Httpd-2.4.25:wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.25.tar.gz
Serf-1.3.9:wget https://www.apache.org/dist/serf/serf-1.3.9.tar.bz2
Scons-2.5.1:wget http://prdownloads.sourceforge.net/scons/scons-2.5.1.tar.gz
Sqlite-amalgamation-3190300:wget Http://www.sqlite.org/2017/sqlite-amalgamation-3190300.zip
Apr-1.5.2:wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.5.2.tar.gz
Apr-util-1.5.4:wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
Results after download:
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/99/03/wKiom1lCs7aAGGEYAAEbG_ib1bU197.png-wh_500x0-wm_ 3-wmp_4-s_4212267782.png "title=" Svn01_prepare.png "alt=" Wkiom1lcs7aaggeyaaebg_ib1bu197.png-wh_50 "/>

3. Compiling the installation
3.1 Preparation
Given the need for some dependent library support during the compilation process, install it by using the following command:
Yum install zlib zlib-devel OpenSSL openssl-devel–y
In addition, because serf needs to be compiled with SCons, and the compiler scons needs python support, Python is required to install:
Yum Install Python–y
3.2 Compiling and installing Apr
Cd/root
Tar zxvf/root/apr-1.5.2.tar.gz
Cd/root/apr-1.5.2/
./configure--PREFIX=/USR/LOCAL/APR
Make && make install
Description: Apr-util relies on Apr, so it takes precedence over Apr-util compilation. The--PREFIX=/USR/LOCAL/APR in the parameter indicates that the compiled installation directory is/USR/LOCAL/APR.
3.3 Compiling and installing Apr-util
cd/root/
Tar zxvf/root/apr-util-1.5.4.tar.gz
cd/root/apr-util-1.5.4/
./configure--prefix=/usr/local/apr-util--WITH-APR=/USR/LOCAL/APR
Make && make install
Note: The--prefix=/usr/local/apr-util in the parameter indicates that the compiled installation directory is/usr/local/apr-util, and the--with-apr=/usr/local/ The APR parameter specifies its dependency on the APR directory as/USR/LOCAL/APR.
3.4 Compiling and installing SCons
cd/root/
Tar zxvf./scons-2.5.1.tar.gz
Cd/root/scons-2.5.1/
Python setup.py Install--prefix=/usr/local/scons
Description: Serf must be compiled with scons, so it takes precedence over serf compilation. The--PREFIX=/USR/LOCAL/APR in the parameter indicates that the compiled installation directory is/USR/LOCAL/APR.
3.5 Compiling and installing serf
cd/root/
Tar XF./serf-1.3.9.tar.bz2
cd/root/serf-1.3.9
/usr/local/scons/bin/scons Prefix=/usr/local/serf apr=/usr/local/apr Apu=/usr/local/apr-util
/usr/local/scons/bin/scons Install
Description: The parameter-Prefix=/usr/local/serf indicates that the compiled installation directory is/usr/local/serf.
3.6 Compiling and installing Apache (httpd)
Cd/root
Tar zxvf/root/httpd-2.4.25.tar.gz
cd/root/httpd-2.4.25
./configure--prefix=/usr/local/httpd-2.4.25--enable-dav--enable-so--enable-ssl--enable-cgi--enable-rewrite--wi Th-zlib--with-pcre--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util--enable-modules=most-- Enable-mpms-shared=all--with-mpm=event--enable-proxy--enable-proxy-fcgi--enable-dav--enable-dav-fs-- Enable-maintainer-mode
Make && make install
Description: The generated mod_dav_svn.so and mod_authz_svn.so are copied to the/usr/local/httpd-2.4.25/modules directory due to subverion compilation, and the/usr/local/ Httpd-2.4.25/conf/httpd.conf is set to auto-load. The--prefix=/usr/local/httpd-2.4.25 in the parameter indicates that the compiled installation directory is/usr/local/httpd-2.4.25.
3.7 Installing Subverion
Since compiling subversion requires SQLite support, the downloaded Sqlite-amalgamation-3190300.zip is decompressed and the folder is renamed to Sqlite-amalgamation and copied to/root/ The SUBVERSION-1.9.5/directory.
Cd/root
Tar zxvf./subversion-1.9.5.tar.gz
Unzip/root/sqlite-amalgamation-3190300.zip
Mv/root/sqlite-amalgamation-3190300/root/subversion-1.9.5/sqlite-amalgamation
cd/root/subversion-1.9.5
./configure--prefix=/usr/local/svn--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util--with-serf=/usr /local--enable-mod-activation--with-apache-libexecdir=/usr/local/httpd-2.4.25/modules--with-apxs=/usr/local/ Httpd-2.4.25/bin/apxs--without-berkeley-db
Make && make install
Support has completed the compilation and installation of Subversion and Apache, where the compiled installation directory is set to the/usr/local directory via the-prefix parameter.
4. Configuration
4.1 User Configuration
The process of subversion in this instance and the Apache process will run as SVN, so you need to create an SVN user account.
Useradd svn-s/sbin/nologin–m
4.2 environment variable configuration
In order to facilitate the need to enter lengthy path information (or switch to its directory) each time the command is run, this series of articles is added to the current application as an environment variable, similar to the set PATH environment variable in Windows, which is configured in CentOS7 in/etc/profile, Content that is currently added at the end of the file:
Export java_home=/usr/local/jdk1.8.0_131
Export jre_home=/usr/local/jdk1.8.0_131
Export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export path= $PATH: $JAVA _home/bin:/usr/local/apache-tomcat-8.5.15/bin:/usr/local/httpd-2.4.25/bin:/usr/local/svn /bin:/usr/local/php/bin
The paths to the executable files for SVN, Tomcat, PHP, Java, and Apache are added to the PATH environment variable, which can be executed directly at a later time.
Finally, let's make our configuration work by Source/etc/profile.
4.3SVN Configuration
Because the SVN executable path is added to the path variable in/etc/profile, the files in the bin subdirectory of the SVN installation directory can be executed directly, such as the version of SVN--version. But the first time you execute the SVN--version command, you get an error:
Svn:error while loading shared libraries:libserf-1.so.1:cannot open Shared object file:no such file or directory
The workaround is to manually create the serf-1.3.9.conf file in the/etc/ld.so.conf.d/directory, which is the directory where the Libserf-1.so.1 file is located, libserf-1.so.1 in the virtual machine/usr/local/ LIB, so the contents of the serf-1.3.9.conf file are as follows:
/usr/local/lib
Save and exit the file and view the loading status by using the following command:
/sbin/ldconfig–v
4.3.1 Creating an SVN repository
Mkdir-p/VAR/SVN
Cd/var/svn
Svnadmin Create Phpproject
Svnadmin Create Javaproject
Svnadmin Create Dotnetproject
That is to create the/VAR/SVN directory, which is the root directory of SVN, and in this directory, the Phpproject, Javaproject, and Dotnetproject three repository are created in turn.
Because we finally wanted subversion to support multiple repositories, the information about SVN accounts and authorizations could not be placed under a separate library, so we placed them directly in/VAR/SVN, the SVN version Coogan directory, mostly three files:
Authz: The authorization information used to store the repository.
passwd: Used to store account numbers and passwords.
Svnserve.conf: A configuration file that is used for svnserve form initiation.
We copy these three files from the Phpproject repository and then modify the control file as a multi-repository based on them:
Cp/var/svn/phpproject/conf/authz/var/svn/authz
cp/var/svn/phpproject/conf/passwd/var/svn/passwd
Cp/var/svn/phpproject/conf/svnserve.conf/var/svn/svnserve.conf
4.3.2 Create SVN account
For security reasons, the user password is processed and saved to a file, which requires the use of Apache's HTPASSWD tool, which can generate passwd files, where the user name is clear text, the user password is MD5 hash value.
Htpasswd-c/var/svn/passwd Jerry #once only
HTPASSWD/VAR/SVN/PASSWD Harry
HTPASSWD/VAR/SVN/PASSWD Root
HTPASSWD/VAR/SVN/PASSWD Admin
HTPASSWD/VAR/SVN/PASSWD Haley
Note: htpasswd is located in/usr/local/httpd-2.4.25/bin, the directory we specified when we compiled the Apache installation, because/usr/local/httpd-2.4.25/bin was added to/etc/profile, So you can directly htpasswd, if the specified directory does not exist passwd file, you need to take the "-C" parameter, to create a file, but then no need. If you take them each time, you only have the last execution result.
The resulting file contents are as follows:
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/99/03/wKioL1lCs86iOIHWAACWYgof_P0413.png-wh_500x0-wm_ 3-wmp_4-s_1926786505.png "title=" Svn05_svn_password.png "alt=" Wkiol1lcs86ioihwaacwygof_p0413.png-wh_50 "/>
4.3.3 Edit svnserve.conf file
Can be edited by vim/var/svn/svnserve.conf, the final file content is as follows:
[General]
Anon-access = Read
auth-access = Write
Password-db = passwd
Authz-db = Authz
[SASL]

4.3.4 Edit Config svn authorization file
Execute command vim/var/svn/authz to edit, the final file content is as follows:
[Aliases]
# Joe =/c=xz/st=dessert/l=snake City/o=snake oil, ltd./ou=research Institute/cn=joe Average

[Groups]
# harry_and_sally = harry,sally
# Harry_sally_and_joe = Harry,sally,&joe
Developers = Jerry,haley
Administrators = Root,admin

[/]
@administrators =RW
Haley = R
Jerry = RW
* = R

[javaproject:/]
@administrators = R
@developers = RW

[phpproject:/]
Root = RW
Haley = RW
Jerry = R

[dotnetproject:/]
@administrators = RW
Jerry = RW
Note: In the above file with "@" is a user group, for example dotnetproject this repository Administrators group has read and write permissions, and Jerry This user also has read and write permissions, and other users do not have permissions.

4.3.5 Mandatory Development Each commit code must be filled with comments
By default, it is optional to fill in comments each time the code is submitted, but in a multiplayer team, if you do not fill in the comments each time you submit the code is to fix the bug or add new features, it is necessary to force it, here to require a comment must not be less than 5 characters per submission as an example.
When we pass the svnadmin create repository, there is a hooks directory under each repository, there are many examples of hooks. A copy of the Pre-commit.tmpl in the Hooks subdirectory under any of the projects that have been created is named Pre-commit, and according to the file name words too literally it is a hook that executes before the code is submitted to the SVN repository.
Now to edit pre-commit:
Vim/var/svn/pre-commit
The final result of the file is as follows:
Repos= "$"
Txn= "$"

# Make sure that the log message contains some text.
Svnlook=/usr/local/svn/bin/svnlook
# $SVNLOOK Log-t "$TXN" $REPOS "| \
# grep "[a-za-z0-9]" >/dev/null | | Exit 1
logmsg= ' $SVNLOOK log-t "$TXN" $REPOS "| grep "[\w\u4e00-\u9fa5]" | Wc-c '
If ["$LOGMSG"-lt 5];
Then
Echo-e "Comment Cann ' t be empty! You must input more than 5 chars as comment! " 1>&2
Exit 1
Fi
Set-e
# Check The author of this commit have the rights to perform
# The Commit on the files and directories being modified.
#commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg | | Exit 1

# All checks passed, so allow the commit.
Exit 0
Then add executable permissions to Pre-commit
chmod 755/var/svn/pre-commit

Then copy the Pre-commit file to the hooks directory of several other repositories:
Cp/var/svn/pre-commit/var/svn/phpproject/hooks
Cp/var/svn/pre-commit/var/svn/javaproject/hooks
Cp/var/svn/pre-commit/var/svn/dotnetproject/hooks
Note: Each time you create a new repository, copy the pre-commit to its hooks directory.
Here we can start the SVN server from the command line, with the following command:
Svnserve--config-file/var/svn/svnserve.conf-d-R/VAR/SVN
That is, with/var/svn/svnserve.conf as the configuration file, the SVN repository root directory is/VAR/SVN, and then you can manipulate the repository with the SVN command under the command.
4.4subverion integration with Apache
It is also possible to use the SVN protocol directly, but it is now more popular to integrate Subverion with Apache and then use a web-based SVN management tool so that SVN can be managed much more easily. In this section, we will talk about Subverion integration with Apache.
Because Nginx is already installed on the current server as a Web server, and 80 ports are used, you have to let Apache use port 8000. Here, there is an introduction to the integration of SVN and Apache on the web, and there is little introduction to SVN and Nginx integration. I looked up some English materials, found on the Nginx website also someone asked this question in 2007, and Nginx author, Russia's Igor Sysoev also answered this question, the website is: http://mailman.nginx.org/pipermail/ Nginx/2007-january/000504.html, according to the author's statement is possible through the configuration support, but I have not tried, there is interested can try.
Modification of 4.4.1httpd.conf
In the Apache configuration file httpd.conf need to be modified where:
Modify the listening port, changed from 80 to 8000;
Changes to the user and group used by the Apache runtime are modified by daemon to SVN;
Include a file on SVN configuration with file name httpd-svn.conf, located in/usr/local/httpd-2.4.25/conf/extra/. Note: This file is not set by default and will be created later.
At the same time, in order to facilitate tracking Apache logs by day, using the rotatelogs in the/usr/local/httpd-2.4.25/bin/directory to cut log files, so that errorlog and Customlog configuration becomes:
Errorlog "|/usr/local/httpd-2.4.25/bin/rotatelogs/usr/local/httpd-2.4.25/logs/error_log.%y%m%d 86400 480"
Customlog "|/usr/local/httpd-2.4.25/bin/rotatelogs/usr/local/httpd-2.4.25/logs/access_log.%y%m%d 86400 480" common
In the above command, 86400 is divided in days, 86400 is the total number of seconds in a day, and 480 is divided by the time of the East Eight time zone (8 hours and 480 minutes apart from UTC).
At the same time, due to compile-time parameter development, multiple MPM modules are enabled, leaving only one to leave the remaining comments out, otherwise the startup error. Before and after the modification for example:
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/99/03/wKioL1lCs-uwxzTHAABqs1aJidk214.png-wh_500x0-wm_ 3-wmp_4-s_4231854224.png "title=" Svn06_svn_httpd_config.png "alt=" Wkiol1lcs-uwxzthaabqs1ajidk214.png-wh_50 "/>
The red box is the modified content, and the bottom is the content before the change.
4.4.2 adds SVN-related matching in ApacheReset
First, the httpd-svn.conf file mentioned earlier in the/usr/local/httpd-2.4.25/conf/extra/directory is created:
Vim/usr/local/httpd-2.4.25/conf/extra/httpd-svn.conf
The contents of the file are as follows:
<Location/svn>
DAV SVN
#support more repositories
Svnparentpath/var/svn

#list all repositories
#SVNListParentPath on
AuthType Basic
AuthName "Please input Username and Password"
authuserfile/var/svn/passwd
Authzsvnaccessfile/var/svn/authz
Require Valid-user
</Location>
The configuration of the multi-repository is used here, and the Svnparentpath setting is used, and the user account and authorization information are the files that point to the root directory of the SVN repository.
4.4.3 Permission Settings
Because Apache is set to run SVN/SVN this user/group, you need to have the SVN account have read and write/VAR/SVN directory permissions, executable command:
Chown–r SVN:SVN/VAR/SVN

5. Inspection configuration
https://tortoisesvn.net/downloads.html Download the TORTOISESVN client corresponding to the operating system, you can checkin and checkout the code.
As the Checkout interface:
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/99/03/wKiom1lCtADijuFDAACJ3bBcjtE475.png-wh_500x0-wm_ 3-wmp_4-s_1367281996.png "title=" Svn02_checkout.png "alt=" Wkiom1lctadijufdaacj3bbcjte475.png-wh_50 "/>
is the error interface when the comment does not reach the setup requirement at the time of submission:
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/99/03/wKioL1lCtBPgRUmQAADDibNf2YE230.png-wh_500x0-wm_ 3-wmp_4-s_1421454993.png "title=" Svn03_checkin_error.png "alt=" Wkiol1lctbpgrumqaaddibnf2ye230.png-wh_50 "/>

is to open the SVN repository interface in the browser:
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/99/03/wKioL1lCtCSCmUsJAACmm1EzC6M735.png-wh_500x0-wm_ 3-wmp_4-s_2552094089.png "title=" Svn04_apache_view.png "alt=" Wkiol1lctcscmusjaacmm1ezc6m735.png-wh_50 "/>6. Summary
In the past more than 10 years, I have used vss/tfs/starteam/svn/git as source Code version Control tool, at present the price is cheaper or even free and practical and convenient is SVN and git. This article is about how to compile and install subversion and httpd (that is, Apache) and make it integrated.

This article is from the "Zhou Gong (Zhou Jinchao) column" blog, please be sure to keep this source http://zhoufoxcn.blog.51cto.com/792419/1937326

Developers learn Linux (8): CentOS7 Compile and install Subversion1.9.5 and Apache2.4.25 and integrate

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.