Install Apache SVN (Subversion) on CentOS 7 / RHEL 7

Subversion, widely known as SVN, is open source version control system used for storing the historical changes of source file and documents, and manages it over a period of time. This post helps you to setup SVN on CentOS 7.

Installing WebServer:

Update the system.
yum update
Here we will install Apache server as webserver for the SVN repository.
yum -y install httpd httpd-tools
Allow httpd through firewall
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload
Start the Apache and verify it by visiting http://your.ip.address.
systemctl start httpd.service

Installing Subversion:

Once the Apache is installed, issue the following command to install subversion.
yum -y install subversion subversion-tools mod_dav_svn

Configuring Subversion:

Once the installation is done, you can start to create repositories as per the requirements. In my case i am creating /svn as the base and will create the repository in it.
mkdir /svn
Create the repository called “testrepo”
svnadmin create /svn/testrepo
Change the permission of the repository in such a way that Apache can read and write.
chown -R apache:apache /svn/testrepo/
If you have SELinux enabled on the system, run the following command.
chcon -R -t httpd_sys_content_t /svn/testrepo/
chcon -R -t httpd_sys_rw_content_t /svn/testrepo/
Configure virtual host in Apache.
vi /etc/httpd/conf.d/svn.conf
Place the following content.
<location /svn>
DAV svn
SVNParentPath /svn
</location>
Restart the apache server.
systemctl reload httpd.service
Access the SVN using the browser, url will be http://your-ip-address/svn/testrepo. It wont ask you any password to view.
CentOS 7 - SVN Without Authendication
CentOS 7 – SVN Without Authendication

Securing SVN: (Optional)

The above setting would allow the anonymous users to view and committing the files. To stop the anonymous access, you have to edit the apache configuration which was created just two steps before.
vi /etc/httpd/conf.d/svn.conf
Place the following content.
<location /svn>
DAV svn
SVNParentPath /svn/
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /etc/subversion/svn.users
Require valid-user
</location>
Created the password file for the user.
htpasswd -cm /etc/subversion/svn.users raj
Restart the apache server.
systemctl reload httpd.service

Testing Subversion:

You can visit the url http://your-ip-address/svn/testrepo to check out the content, you will be asked to enter the user name and password (If you have setup the Secure SVN.
CentOS 7 - SVN With Authendication Asking Password
CentOS 7 – SVN With Authentication Asking Password
Upon successful login; content will be listed like below.
CentOS 7 - SVN With Authendication
CentOS 7 – SVN With Authentication
Create a template directory and  import into SVN.
mkdir -p /tmp/repository/project1/{trunk,branches,tags}
svn import -m 'Initial Import' /tmp/repository/project1/ http://192.168.12.106/svn/testrepo
Output will be like below.
CentOS 7 - SVN Import
CentOS 7 – SVN Import
Check out the Revision 1.
CentOS 7 - SVN Revision 1
CentOS 7 – SVN Revision 1
That All!.. You can use the SVN client such as Tortoisesvn for windows and Rapidsvn for Linux.

Nhận xét

Đăng nhận xét

Bài đăng phổ biến từ blog này

CLEANING UP THE ZABBIX DATABASE

Configuring DHCP Relay service on the FortiGate unit

[Resolved] Amazon EC2 Redhat 7 using 6GB for the root space