Install Subversion 1.9.7 on CentOS7

Because the project needs to build an SVN server in the CentOS 7.4 environment, but the subversion version that comes with CentOS is only up to 1.7.14

It is far from the SVN 1.8.19 and SVN 1.9.7 released on the Subversion official website on August 10, which will seriously affect the use of the SVN client. Therefore, we need to uninstall the built-in Subversion and reinstall the latest version of Subversion using yum.

we execute the command

yum remove subversion*

yum clean all

Uninstall subversion and related library packages directly

But when we use the yum command to install subversion again, we find that the version of Subversion that comes with the CentOS source is still 1.7.14

It means that it is impossible to install the latest version of Subversion from the source that comes with CentOS. We need to add the Repo source separately.

Referring to https://tecadmin.net/install-subversion-1-8-on-centos-rhel/#, we are in

Add the subversion.repo file to the /etc/yum.repos.d directory with the following contents

[Subversion]
name=Wandisco SVN Repo
baseurl=http://opensource.wandisco.com/centos/$releasever/svn-1.9/RPMS/$basearch/
enabled=1
gpgcheck=0

Since we are installing SVN1.9 here, svn-1.9 is configured in the repo file. If you want to install SVN1.8, you can change it to svn-1.8

Execute the yum install -y subversion command to install Subversion

The following steps refer to the article https://www.cnblogs.com/fuyuanming/p/6123395.html,

Some have been modified

1) Create the user svn required to run the SVN server

groupadd svn
useradd -g svn svn

The reason why we need to create the svn user to start the SVN server instead of using the root user to start the SVN server is because if the root user is used to start the SVN server, and the SVN server is accessed through the SVN client using a non-root account, an error message will appear.

"xxxxxxxx db/txn-current-lock:permission denied"错误。

Add the svn user to the sudoers user

2) Execute the rpm -ql subversion command to understand the location of the SVN installation

3) Create SVN repository folder

mkdir -p /opt/svnRepos

Switch to the svn user and add access to this folder for the svn user

sudo chmod -R o+rw /opt/svnRepos

4) Create SVN repository

svnadmin create /opt/svnRepos

After executing the command, some new folders are added under the /opt/svnRepos folder

5) Add user password and access rights

Enter the conf directory, you can see the following files

The authz file is the permission control file

passwd is the account password file

svnserve.conf is the SVN service configuration file

Modify the passwd file and add the user svnuser1 and access password in the [users] section

Modify the authz file and add the svn root directory access permission for the svnuser1 user at the end of the file

Here [/] indicates that it is the svn root directory, and svnuser1=rw indicates that the svnuser1 user has read and write permissions to the root directory. If you want to restrict certain users to certain folders

Read and write permissions, [/] here can be changed to a specific folder directory, and then add specific user permissions, which will not be repeated here.

6) Modify the svn configuration file

Modify the svnserve.conf file

Open the comments for the following items (marked in white font in the figure)

anon-access = read # Readable by anonymous users

auth-access = write #Authorized users can write

password-db = passwd #Which file is used as the account file

authz-db=authz #Which file to use as the authority file

realm = /opt/svnRepos # Authentication space name, the directory where the repository is located

7) Start the SVN server

Execute the following command

svnserve -d -r /opt/svnRepos --config-file=/opt/svnRepos/conf/svnserve.conf

The parameter -d of this command means to run the Svn server in the form of a daemon process, -r means the root directory of the Svn server, followed by the root directory of the SVN.

--config-file is the configuration file referenced by the Svn server startup, followed by the configuration file path.

More parameters of the svnserve command can refer to this article

https://linux.die.net/man/8/svnserve

After startup, you can see that the svnserve process has been started

8) Open the SVN server port on the firewall

The default port of the SVN server is 3690. If you want to modify the default port, you can add the --listen-port parameter when running the svnserve command, followed by the port number that needs to be specified.

Run the following command to open the SVN server port on the CentOS7 system firewall

firewall-cmd --permanent --add-port=3690/tcp

systemctl restart firewalld.service

Install Tortoise SVN 1.9.7 on the client. After the installation is complete, create a new folder, right-click in the folder, select the [Repo-brower] menu in the pop-up context menu, and enter SVN:// in the pop-up address dialog box. IP (we are SVN://192.168.56.102 here), and then enter the user name rick and password in the verification dialog box, you can access the SVN root directory, we use the svnuser1 user to log in to SVN, as shown in the following figure

 

We use the svnuser1 user to create three folders: trunk, tags and branches in the root directory

9) Set the SVN server to start the service on boot.

There are related files on the Internet to set the SVN server to start up by modifying the /etc/rc.local file. This practice is outdated in the CentOS 7 environment. We use the CentOS 7 method of adding services normally.

We switch to the /usr/lib/systemd/system directory, create a file named svnserver.service, and add the following content

[Unit]
Description=SVN Server service  
After=network.target

[Service]
Type=forking
ExecStart= /usr/bin/svnserve -d -r /opt/svnRepos --config-file=/opt/svnRepos/conf/svnserve.conf
ExecStop=  /home/svn/stopSVN.sh
User=svn
Restart=on-abort

[Install]
WantedBy=multi-user.target

Here I start the SVN server and use the command directly. I tried to write a .sh file to replace it, but the code=exited, status=203/EXEC error appeared after startup, and the current form was used instead.

stopSVN.sh is the script file used to shut down the SVN service. The contents are as follows:

#!/bin/sh
#查找是否有svnserve对应的进程,有的话关闭进程
ps -ef|grep svnserve |grep -v grep
if [ $? -ne 0 ]
then
   echo "the svn server does not start"
else
   killall -9 sh svnserve
fi
#####

After saving the svnserver.service file, execute the following command

systemctl daemon-reload
systemctl enable svnserver.service
systemctl start svnserver.service

If there is no error message in the shell window, indicating that the startup has been successful, we can execute the following command to check the startup status

systemctl status svnserver.service

Run the following command to stop the service

systemctl stop svnserver.service

We then run systemctl stop svnserver.service again, and we can see that the service has been stopped

So far, the SVN server has been successfully installed on the Linux server. After restarting the CentOS system, the SVN server will start up.

In addition, the SELinux that comes with CentOS is Enforcing by default, which is open. For the self-starting SVN service, it will cause a Permisson Denied error when the client accesses the SVN server. We need to manually close it and modify /etc/selinux/config document

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Change SELINUX from enforcing to disabled, restart the system, after the SVN service starts, the Permssion Denied error no longer occurs when accessing from the client.

Guess you like

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